@Bosdragon : Sorry it took me so long to reply!
I experienced the same crash after adding the mod to an existing single-player game. The problem is that in single player mode, on_player_joined_game
will be raised only once (directly after on_player_created
), not when loading a saved game. The only place where player data could be initialized in this case would be in on_configuration_changed
, but the mod only migrates tables there and doesn't create new ones. […]
I've fixed the crash by replacing lines 26 and 27 of libraries/update.lua with this:
for _, v in pairs(game.players) do
global.player_info[v.index] = global.player_info[v.index] or {color = v.color}
if v.gui.relative.player_color_sprite_button_open ~= nil then
I can't get this to work, I still get the same error.
Strange …
When you say 'replace lines 26 and 27' do you mean put these three lines instead? It's kinda confusing because you put 3 lines of code that are supposed to replace 2 lines of code, maybe I got something mixed up?
Yes, the 3 lines are meant to replace 2 lines in the original file. Actually, I've only added the second line, the others haven't changed. My idea was that this directive would make it easier to get the new line at the correct position. I'm sorry that confused you!
Basically, I want to check for each player in the game whether global.player_info already exists for that player, and initialize the table if it doesn't exist. Therefore, this line must be after for _, v in pairs(game.players)
. But I must always check this -- whether v.gui.relative.player_color_sprite_button_open
exists or not. That's why the new line must be placed before the line starting with ìf`. Hope that helps. :-)