Prevent doors closing through occupants
This commit is contained in:
parent
bf09a8844a
commit
9731202739
5 changed files with 108 additions and 6 deletions
5
door.lua
5
door.lua
|
|
@ -11,6 +11,7 @@ function Door:initialize(x, y, color)
|
|||
collision = "unmoveable",
|
||||
sprite = loadSprite("art/game/door_" .. color:sub(1, 1) .. ".png"),
|
||||
})
|
||||
self.isDoor = true
|
||||
self.locked = true
|
||||
self:refreshSprites()
|
||||
end
|
||||
|
|
@ -27,10 +28,10 @@ function Door:refreshSprites()
|
|||
self.sprites = { [self.doorColor] = sprite }
|
||||
end
|
||||
|
||||
function Door:setColors(colors)
|
||||
function Door:setColors(colors, canClose)
|
||||
if colors[self.doorColor] then
|
||||
if self.locked then self:unlock() end
|
||||
else
|
||||
elseif canClose ~= false then
|
||||
if not self.locked then self:lock() end
|
||||
end
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue