From c41930fca4e5d8765d1aafaaafb62112d41a4967 Mon Sep 17 00:00:00 2001 From: Kazhnuz Date: Wed, 1 May 2019 17:21:38 +0200 Subject: [PATCH] modules/world: automatize multiple character handling --- gamecore/modules/world/baseworld.lua | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/gamecore/modules/world/baseworld.lua b/gamecore/modules/world/baseworld.lua index 108e63e..43f9b51 100644 --- a/gamecore/modules/world/baseworld.lua +++ b/gamecore/modules/world/baseworld.lua @@ -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)