Hi,
I've had a report that my mod was causing desync in MP games.
I can't test this and was hoping I could get the community to help me out with this.
The only change I made was to move my Artifact Collector from another mod to this mod. I also made some functions 'local' functions.
I did not have any issues like this before, so the obvious culprit would be the Artifact Collector stuff.
Again, I'd appropriate it if someone could please help me test this, since I don't do MP myself.
I've attached the mod.
Thanks!
Mod issue - desync in MP
Mod issue - desync in MP
- Attachments
-
- Natural_Evolution_Buildings_7.2.2.zip
- NE Buildings
- (2.44 MiB) Downloaded 93 times
Re: Mod issue - desync in MP
Your variables here:TheSAguy wrote:Hi,
I've had a report that my mod was causing desync in MP games.
I can't test this and was hoping I could get the community to help me out with this.
The only change I made was to move my Artifact Collector from another mod to this mod. I also made some functions 'local' functions.
I did not have any issues like this before, so the obvious culprit would be the Artifact Collector stuff.
Again, I'd appropriate it if someone could please help me test this, since I don't do MP myself.
I've attached the mod.
Thanks!
Code: Select all
if not NE_Buildings_Config then NE_Buildings_Config = {} end
if not NE_Buildings_Config.mod then NE_Buildings_Config.mod = {} end
if not NE_Buildings then NE_Buildings = {} end
if not NE_Buildings.Settings then NE_Buildings.Settings = {} end
Re: Mod issue - desync in MP
You are mixing stdlibs event system with factorios event system.
Event.register is registing on_tick to one thing, and script.on_event is registering on_tick to something else and has conditionals. Pick one system to use, And I recomend against using conditional registration for on_tick for now due to the complexity. Only 1 function can be registered per event, stdlib adds an iteration layer in between. Event.register is ok to use but when using it you loose a lot of the protections built into script.on_event
Secondly you are storing stuff in non global as per Klonans post but the problem goes slightly deeper. If any of those settings you are saving into them get changed you don't have an on_mod_settings_changed events to update them....
Event.register is registing on_tick to one thing, and script.on_event is registering on_tick to something else and has conditionals. Pick one system to use, And I recomend against using conditional registration for on_tick for now due to the complexity. Only 1 function can be registered per event, stdlib adds an iteration layer in between. Event.register is ok to use but when using it you loose a lot of the protections built into script.on_event
Secondly you are storing stuff in non global as per Klonans post but the problem goes slightly deeper. If any of those settings you are saving into them get changed you don't have an on_mod_settings_changed events to update them....
Re: Mod issue - desync in MP
Thanks Klonan and Nexela for looking at my mod.
I think I've made the needed changes.
Made the settings stuff global.
I changed to stdlibs for on_tick:
I changed:
to
I changed:
to
Can someone please explain the above two functions to me. Why have anything at all if have the 'nil' there? I would like to understand the function of this.
Is there anything I've missed?
Thanks again!
I think I've made the needed changes.
Made the settings stuff global.
I changed to stdlibs for on_tick:
I changed:
Code: Select all
script.on_event(defines.events.on_tick, function(event) ticker(event.tick) end)
Code: Select all
Event.register(defines.events.on_tick, function(event)
ticker(event.tick)
end)
Code: Select all
script.on_event(defines.events.on_tick, nil)
Code: Select all
Event.register(defines.events.on_tick, nil)
Is there anything I've missed?
Thanks again!
- Attachments
-
- Natural_Evolution_Buildings_7.2.3.zip
- Updated Mod
- (2.44 MiB) Downloaded 88 times
Re: Mod issue - desync in MP
The second one is from stdlib stdlib/event/
event.lua