Desync

Place to get help with not working mods / modding interface.
Post Reply
blueblue
Long Handed Inserter
Long Handed Inserter
Posts: 75
Joined: Tue Apr 11, 2017 7:39 pm
Contact:

Desync

Post by blueblue »

I'm getting reports by multiple users that a mod I created causes desyncs, likely in combination with other mods. Is there anything I should change about my mod or is this something for the devs to fix? I am currently not in a situation where I can attempt to reproduce the desync.
unique_2 on discord and mod portal

Nexela
Smart Inserter
Smart Inserter
Posts: 1828
Joined: Wed May 25, 2016 11:09 am
Contact:

Re: Desync

Post by Nexela »

Assuming you are talking about ore chaos mod

Code: Select all

local strategies_outside_starting_area = {}
local strategies_all = {}
local strategy_cache_start_area = {}
local strategy_cache_all = {}
local starting_area_radius = 0
local prototype_infinite_errors = {}
local rso_active = false
local angels_active = false
local active = true
Without following through on all the code I am pretty sure most of those variables will need to be stored in the global. variable.
Does the variable change and will it be used in another tick. If the answer to those are yes then you need to store your variables in the global. variable

on_init -> create the variables with default values: global.starting_area_radius = 200
on_configuration_changed -> --The easy way (not always the best but usually works) if event.mod_changes and event.mod_changes["my-mod-name"] then global.starting_area_radius = global.starting_area_radius or 200

blueblue
Long Handed Inserter
Long Handed Inserter
Posts: 75
Joined: Tue Apr 11, 2017 7:39 pm
Contact:

Re: Desync

Post by blueblue »

Thank you for the comprehensive answer!

Since my google-fu is evidently lacking, is this documented somewhere? I feel I went through a good bit of the lua-api pages now, which is where I would expect this kind of thing to come up.
unique_2 on discord and mod portal

Rseding91
Factorio Staff
Factorio Staff
Posts: 13229
Joined: Wed Jun 11, 2014 5:23 am
Contact:

Re: Desync

Post by Rseding91 »

If you want to get ahold of me I'm almost always on Discord.

blueblue
Long Handed Inserter
Long Handed Inserter
Posts: 75
Joined: Tue Apr 11, 2017 7:39 pm
Contact:

Re: Desync

Post by blueblue »

Can we please put "Use the global table for stuff that is not local to a single tick, otherwise you get desyncs in multiplayer" somewhere near that page? This page only tells me to use it for data that I need to persist between save/load.
unique_2 on discord and mod portal

Post Reply

Return to “Modding help”