Hello! This is a very cool mod! I had a quick look at your code. The desync could be caused by the
local reloaded = false
Any variable that might change during the runtime of the mod needs to be stored in storage
, otherwise it will desync.
And a little note, I see there's some magic numbers in your code. Might be easier to maintain if you if you change it like this :)
if local_player.render_mode == defines.render_mode.game or local_player.render_mode == defines.render_mode.chart_zoomed_in then
instead of
if local_player.render_mode == 3 or local_player.render_mode == 1 then
(I'm quessing the actual defines used, but you get the idea :)