I get this error when running the following code which looks like it's treating player_index as a table not an integer? Didn't see any bugs on this one - with a 2 second glance. My on_player_joined_game version of the same thing is working fine but it uses event as a parameter.
Code: Select all
Error while running event CityPeeps::on_player_left_game (ID 44)
__CityPeeps__/scripts/civ_logic.lua:89: attempt to concatenate local 'player_index' (a table value)
Code: Select all
script.on_event({defines.events.on_player_left_game},
function(player_index)
Civ:player_left(player_index)
end)
Code: Select all
function Civ:player_left(player_index)
game.players[1].print("Player Left Index: "..player_index) -- THIS IS THE LINE THAT ERRORS (89)
for index, gui in ipairs(self.state.guis) do
if (gui.state.player_index == player_index) then
table.remove(self.state.guis, index) -- THIS LINE NEVER RUNS (which is why I was trying to see the player_index value)
Civ:debug("P1")
end
end
Civ:debug("Player Gui Size: "..#self.state.guis)
end
Edit: I also tried using event.player_index as a parameter but that didn't work either.