Hide Elevated Rail Keybind


Hide your elevated rails using a keybind so you can work underneath

Tweaks
3 months ago
2.0
409
Trains

b Desync in multiplayer

3 months ago

The game desyncs when you toggle the mod in multiplayer.

3 months ago

Yea sorry, as I said I haven't really tested multiplayer since there is no one the help me test it. Can you please provide some more info about what happend?
What went wrong?
What caused the issue?
Can you reproduce the issue? How?
Anyways thanks for the response! :)

3 months ago

Also can you provide a log?

3 months ago

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 :)

3 months ago

Hello thanks for the response, I had already fixed some issues in an update 2 hours ago. Anyways that was indeed the problem! Also thanks for letting me know there are defines for the render mode :) I'll change that rn!

3 months ago
(updated 3 months ago)

No problem. I also looked at the code from version 1.0.1 :)

And just for interest's sake, to replace your reloaded mechanims I'd probably do something like:

local function init()
            remove_hidden_rails()
            storage.player_hidden_setting = {}
            storage.tick_delay_10 = 0
end

script.on_init(init)
script.on_configuration_changed(init)

This will run on save creation, and when some mod configuration changed. Those are the only two events your mod should really care about regarding saving/loading. You can read some more here: https://lua-api.factorio.com/latest/auxiliary/data-lifecycle.html

This thread has been locked.