Can someone explain what "client" executes on_events?
Posted: Fri May 19, 2017 10:01 am
Hi All,
I have a general question about how Factorio works with it's Lua Events (such as on_chunk_generated).
Task: Imagine 3 clients are connected to the game, there is a custom script inside the control.lua of the scenario file that re-rolls generated chunks to randomly spawn new entities, such as ore, or enemy bases, all 3 clients are connected to a headless client acting as the server.
Do all clients run the on_chunk_generated code at the same time?
If so, how does Factorio deal with entities that are randomly selected to be spawned or not?
Let's say that Client 1's random algorithm selected to spawn the entity, the headless client also did, but client 2 and 3's random algorithm selected not too - would this cause a desync due to 2 clients not having spawned the entity on their local map variant causing their map tick to have a different CRC than the rest?
The reason I ask this is because I believe that this is happening for me when new chunks are generated everyone desyncs - perhaps i just need to run the on_chunk_generated code on just a single client's game?
I have a general question about how Factorio works with it's Lua Events (such as on_chunk_generated).
Task: Imagine 3 clients are connected to the game, there is a custom script inside the control.lua of the scenario file that re-rolls generated chunks to randomly spawn new entities, such as ore, or enemy bases, all 3 clients are connected to a headless client acting as the server.
Do all clients run the on_chunk_generated code at the same time?
If so, how does Factorio deal with entities that are randomly selected to be spawned or not?
Let's say that Client 1's random algorithm selected to spawn the entity, the headless client also did, but client 2 and 3's random algorithm selected not too - would this cause a desync due to 2 clients not having spawned the entity on their local map variant causing their map tick to have a different CRC than the rest?
The reason I ask this is because I believe that this is happening for me when new chunks are generated everyone desyncs - perhaps i just need to run the on_chunk_generated code on just a single client's game?