modules/world: automatize multiple character handling

This commit is contained in:
Kazhnuz 2019-05-01 17:21:38 +02:00
parent 767fddadfa
commit c41930fca4

View file

@ -144,6 +144,11 @@ end
function BaseWorld:initPlayers()
self.players = {}
self.playerNumber = 1
end
function BaseWorld:setPlayerNumber(playerNumber)
self.playerNumber = playerNumber or 1
end
function BaseWorld:addPlayer(actor, sourceid, haveCam)
@ -214,8 +219,10 @@ function BaseWorld:loadMapPlayers()
print("DEBUG: loading actors in player layer")
local i = 1
for k, object in pairs(objectlayer.objects) do
self:addPlayer(self.obj.Player(self, object.x, object.y), i, true)
if (i <= self.playerNumber) then
-- TODO: don't hardcode camera handling
self:addPlayer(self.obj.Player(self, object.x, object.y), i, true)
end
i = i + 1
end
self.map:removeLayer(objectlayer.name)