fix state thigns and port to love11
This commit is contained in:
parent
ff5abf6bcd
commit
c92c0f6ff7
11 changed files with 130 additions and 96 deletions
17
room.lua
17
room.lua
|
|
@ -130,7 +130,7 @@ function Room:draw()
|
|||
|
||||
-- npcs (old "sages") are markers for now: a "?" tinted to the player's channels
|
||||
local cellW, cellH = width / gridWidth, height / gridHeight
|
||||
love.graphics.setColor(has.red and 255 or 0, has.green and 255 or 0, has.blue and 255 or 0)
|
||||
love.graphics.setColor(has.red and 1 or 0, has.green and 1 or 0, has.blue and 1 or 0)
|
||||
for _, npc in ipairs(self.npcs) do
|
||||
love.graphics.print("?", (npc.x - 1) * cellW + cellW * 0.3, (npc.y - 1) * cellH + cellH * 0.1, 0, 2, 2)
|
||||
end
|
||||
|
|
@ -698,6 +698,12 @@ end
|
|||
function Room:deserialize(saveTable)
|
||||
for _, obj in ipairs(saveTable.objects or {}) do
|
||||
self:createEntity(obj.class, obj.color, obj.x, obj.y)
|
||||
-- createEntity turns every loaded player on; honour a saved active flag so
|
||||
-- copies that were off at save time stay off (older savs lack the field and
|
||||
-- keep the old all-on behaviour).
|
||||
if obj.class == "player" and obj.active ~= nil then
|
||||
self:setActiveColor(obj.color, obj.active)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
|
@ -752,7 +758,14 @@ function Room:serialize(includePlayers)
|
|||
|
||||
if includePlayers ~= false then
|
||||
for color, player in pairs(self.player) do
|
||||
emit("player", color, player)
|
||||
local pos = player:getGridPos()
|
||||
-- Persist which copies were active so a resume restores exactly the
|
||||
-- channels that were on at save time. A colour deactivated during play
|
||||
-- (see playerJoinCheck) must come back as an inactive copy, not turn on.
|
||||
table.insert(objects, {
|
||||
class = "player", color = color, x = pos.x, y = pos.y,
|
||||
active = self.activeColors[color] and true or false,
|
||||
})
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue