Page 1 of 1

[.14.21] Bob Inserters 0.14.2 Multiplayer Tick bug

Posted: Fri Dec 16, 2016 3:21 am
by Nexela
Bob, Found a bug with using inserters gui in multiplayer.

using game.connected_players the index returned from a for loop is NOT the player index http://lua-api.factorio.com/latest/LuaG ... ed_players
Without this change the gui will close immediately for some players when opening after players in mp disconnect/leave

Fixed code below by replacing index with player.index
on_tick

Re: [.14.21] Bob Inserters 0.14.2 Multiplayer Tick bug

Posted: Sat Dec 17, 2016 12:24 pm
by bobingabout
It's stuff like this that shows I'm pretty much just guessing with the whole thing. If it seems to work, it ships.

Re: [.14.21] Bob Inserters 0.14.2 Multiplayer Tick bug

Posted: Sat Dec 17, 2016 12:40 pm
by Nexela
You do a pretty good job of guessing :)

I would have never been able to figure out what the problem was if I had just not used game.connected_players in my own mod.

Re: [.14.21] Bob Inserters 0.14.2 Multiplayer Tick bug

Posted: Sat Dec 17, 2016 1:39 pm
by bobingabout
Well, it's done, uploading.

Actually, I fixed the code myself without copying yours, using your description of the issue, and came to the same result. except using variable _ for dummy, I just renamed index to i.

Re: [.14.21] Bob Inserters 0.14.2 Multiplayer Tick bug

Posted: Sat Dec 17, 2016 1:53 pm
by Nexela
I like to use _ otherwise luacheck throws warnings about unused variables :)

Re: [.14.21] Bob Inserters 0.14.2 Multiplayer Tick bug

Posted: Sat Dec 17, 2016 4:57 pm
by bobingabout
to which I'd say. what the heck is luacheck? :P

Re: [.14.21] Bob Inserters 0.14.2 Multiplayer Tick bug

Posted: Sat Dec 17, 2016 5:09 pm
by Nexela
https://github.com/mpeterv/luacheck#overview I can't live without it :) I typically use = instead of == in an if statement and luacheck yells at me as soon as I move to the next line.