Skip to content

call remote APIs when loading the mod - #24

Open
hgschmie wants to merge 1 commit into
robot256:mainfrom
hgschmie:reload-mod
Open

call remote APIs when loading the mod#24
hgschmie wants to merge 1 commit into
robot256:mainfrom
hgschmie:reload-mod

Conversation

@hgschmie

@hgschmie hgschmie commented Aug 5, 2026

Copy link
Copy Markdown

When reloading the game mods (with /c game.reload_mods()), some other mods reset their state (e.g. remove all excluded locomotives).

Calling CallRemoteInterface() at on_load time ensures that the state of these mods get updated again.

When reloading the game mods (with /c game.reload_mods()), some other
mods reset their state (e.g. remove all excluded locomotives).

Calling CallRemoteInterface() at on_load time ensures that the state
of these mods get updated again.
@robot256

robot256 commented Aug 6, 2026

Copy link
Copy Markdown
Owner

From the API docs:

reload_mods()
Forces a reload of all mods.

This will act like saving and loading from the mod(s) perspective.

If the mod is save-load stable, it should not be affected by reload_mods(). If there is a mod that is affected the way you suggest, it is because they are not storing the data given by the remote interface in storage, and that data will be lost every time you save and load the map. What mod are you having this issue with?

The devs are very consistent in saying that on_load should be used as little as possible, because it is the only part of the mod that runs at different times for different clients (when they join a multiplayer server) and thus can easily lead to desyncs. The only thing I use it for is registering conditional events based on the mod state stored in storage.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants