level editor improvements

This commit is contained in:
Your Name 2026-08-07 00:56:33 -04:00
parent 886679816b
commit a8b469876d
41 changed files with 8367 additions and 8312 deletions

View file

@ -16,3 +16,32 @@ end
function lerp(a, b, amount)
return (1 - amount) * a + (amount * b)
end
-- Write to the project tree itself (not LÖVE's save dir) so edits persist in the
-- repo during dev. Uses plain io.open against love.filesystem.getSource(), which
-- is the absolute project path when running `love .` from a folder. Falls back to
-- love.filesystem.write (save dir) if the source is a packaged .love archive.
function writeToSource(relPath, contents)
local base = love.filesystem.getSource()
local file = io.open(base .. "/" .. relPath, "w")
if file then
file:write(contents)
file:close()
return true
end
return love.filesystem.write(relPath, contents)
end
-- Read from the project tree directly so a stale copy in LÖVE's save directory
-- can't shadow the real source file. Falls back to love.filesystem for a
-- packaged .love.
function readFromSource(relPath)
local base = love.filesystem.getSource()
local file = io.open(base .. "/" .. relPath, "r")
if file then
local contents = file:read("*a")
file:close()
return contents
end
return love.filesystem.read(relPath)
end