sav fixes

This commit is contained in:
Your Name 2026-08-07 17:49:13 -04:00
parent 12c37b5fa9
commit 1850737cf6
20 changed files with 3729 additions and 3738 deletions

View file

@ -27,6 +27,10 @@ function Room:initialize(t)
print(t.name)
if t.player then
-- The carried colors are the sole source of truth for what's active.
-- Copies that live in this room (loaded from the sav) start INACTIVE —
-- you must walk onto one to merge it; it never joins you automatically.
self.activeColors = {red = false, green = false, blue = false}
-- entering from another room: place the carried colors at the entry point
for _, color in ipairs(t.player.activeColors) do
if self.player[color] then
@ -97,6 +101,11 @@ function Room:initialize(t)
self.collidableMatrices = {} --{red = {{...}{...}{...}}, ...
self:createSwitchMatrix()
self:createCollideablesMatrix()
-- Resolve switches/doors up front so the very first frame renders correct
-- lock state: a block already sitting on a switch presses it before anything
-- is drawn, instead of waiting for the first move's tick.
self:resolveSwitchesAndDoors()
end
@ -414,11 +423,17 @@ function Room:tick()
end
self:createCollideablesMatrix()
self:createSwitchMatrix()
self:resolveSwitchesAndDoors()
self:nextRoomCheck()
end
-- Run the switch press check and push the result to every door. Assumes the
-- collidable/switch matrices are already current.
function Room:resolveSwitchesAndDoors()
local setDoorColors = self:switchCheck()
for _, door in pairs(self.doors) do
door:setColors(setDoorColors)
end
self:nextRoomCheck()
end
function Room:playerJoinCheck(previousPositions, newPositions)