[Answered] Player inventory concurrent modification woes
Posted: Fri Oct 21, 2016 10:56 pm
I'm having an issue when multiple mods are loaded that alter the player's inventory during on_player_created. I have a few mods which add items to the player's inventory on start, and one which clears the player inventory on start. I'm not having any actual runtime errors, but I'm looking for a simple way to ensure that the mod which clears the player inventory always goes last.
Currently the control.lua is this:
I was initially thinking of having some kind of sleep at the top of the event handler function, but that seems like a rather hacky way to get the job done. Sadly, adding optional mod dependancies didn't seem to help at all.
Currently the control.lua is this:
Code: Select all
script.on_event(defines.events.on_player_created, function(event)
local a_player = game.players[event.player_index]
for i=1,6,1 do
a_player.get_inventory(i).clear()
end
end)