Space Exploration - Annoyances


Removes patreon messages and mod version watermark from Space Exploration mod.

Tweaks
4 months ago
1.1
250

b [Resolved] Potential desync

4 months ago

Hi,

I haven't ran the code yet, but it looks as though it'll cause a desync when players join within 60 ticks of one of those 5 event triggers since the on_nth_tick's aren't stored in global and re-established during script.on_load πŸ€”

Neat mod tho, i sometimes have like 3 of those messages back-to-back when testing stuff πŸ‘€

4 months ago

Yeah I have no clue how it meshes with multiplayer, and I've been in Factorio modding for a total of 3 hours so far. My main concern is for it to work in singleplayer, and if issues arise then we'll see

4 months ago

From what I have read so far - It should just work. Nothing in the API docs or tutorials suggests that on_nth_tick should be treated any differently from other events, and I am not using any of the common desync causers.

4 months ago

the problem is that those 5 events can fire right before when someone downloads the map and will thus not register those events, global will need to be used for those "conditional" on_nth_ticks

4 months ago

Yeah, I missed the "inside a function" part. I love when tutorials use misleading names and provide no solution to the problem πŸ‘
Will upload a fix in a bit, once I figure out how to actually save stuff into global properly

4 months ago

in on_init you'll want something like:
global.on_nth_ticks = {}

(and since the mod already exists you'll need this in on_configuration_changed:
global.on_nth_ticks = global.on_nth_ticks or {}

then when you register the on_nth_tick you'll set global.on_nth_ticks[event.tick] = true

where you unregister the on_nth_tick you'll want to do the same but set it to nil instead

then in on_load have something like this:
for tick, _ in pairs(global.on_nth_ticks) do
script.on_nth_tick(tick, event)
end

i don't believe i forgot anything but this should point you in the right direction

4 months ago

on_load runs before on_configuration_changed, so I would need a nil check there before using pairs(). Decided to go with a migration instead.

But then I though - if events are handled by mods in order of dependencies, then my nth_tick delay isn't even needed here, I can just handle my events immediately and there wouldn't even be any need to deal with all of this. Oh well, just how I usually handled these things in other games.

4 months ago

sounds about right

This thread has been locked.