Understanding multiplayer events, GUI, and desyncs
Posted: Sun Apr 17, 2022 8:45 am
Hi everyone,
disclaimer: I'm super new to writing mods, so expect a couple of noob questions:
I want to write a mod that builds entities, triggered by various events (GUI and other).
I'm trying to understand how exactly GUI events and events in general work in multiplayer context and how to avoid desyncs.
Let's say I have a GUI button which on_click will build some entity right besides the player.
What does actually happen here in mp?
What is being sent over to other clients?
Do other clients get some message to build that entity?
Or do they also just get the GUI on_click event and essentially the same mod needs to "replicate" the behavior of building an entity as a result?
I'm trying to wrap my head around this determinism that is mentioned everywhere... is that what is meant?
I'm also a bit confused about the raise_built parameter in LuaSurface.create_entity() and the events that deal with building.
For events I found on_built_entity as well as script_raised_built.
Why are there two different events here for entities being built?
Why does for example on_entity_renamed have a by_script flag instead?
The script_raised_built is described as static event, what does that mean?
I have a feeling that this has something to do with how multiplayer works...
Is the on_built_entity event ever raised when building an entity from a script?
I was thinking if a player triggers some entity building by clicking the GUI, if I couldn't have this registered as the player having built the entity.
disclaimer: I'm super new to writing mods, so expect a couple of noob questions:
I want to write a mod that builds entities, triggered by various events (GUI and other).
I'm trying to understand how exactly GUI events and events in general work in multiplayer context and how to avoid desyncs.
Let's say I have a GUI button which on_click will build some entity right besides the player.
What does actually happen here in mp?
What is being sent over to other clients?
Do other clients get some message to build that entity?
Or do they also just get the GUI on_click event and essentially the same mod needs to "replicate" the behavior of building an entity as a result?
I'm trying to wrap my head around this determinism that is mentioned everywhere... is that what is meant?
I'm also a bit confused about the raise_built parameter in LuaSurface.create_entity() and the events that deal with building.
For events I found on_built_entity as well as script_raised_built.
Why are there two different events here for entities being built?
Why does for example on_entity_renamed have a by_script flag instead?
The script_raised_built is described as static event, what does that mean?
I have a feeling that this has something to do with how multiplayer works...
Is the on_built_entity event ever raised when building an entity from a script?
I was thinking if a player triggers some entity building by clicking the GUI, if I couldn't have this registered as the player having built the entity.