The mechanism Factorio uses is to sync user inputs, not game state changes (the reason isn’t explained, but I strongly suspect it’s because user inputs are less data; small inputs can cause big game state changes, but not vice versa).
If the user types a command, in order to preserve synchronization, the game must:
- Run the command on all other clients.
- OR it could sync changes made to the game for just commands; in other words, the other clients apply the changes caused by the command instead of running the command directly. But that would be an unreasonable amount of extra work just for a small feature and to make exploits harder.
- OR the server simply disallows clients from running Lua commands, which is the case for some servers.
I don’t get the second part though: why a map can store arbitrary Lua code that runs when the map loads.
(Some time ago, Factorio did not have a built-in mod synchronization system for multiplayer, with the result that the most popular servers did not run any mods, but rather used complicated scenarios instead.)
If the user types a command, in order to preserve synchronization, the game must:
- Run the command on all other clients.
- OR it could sync changes made to the game for just commands; in other words, the other clients apply the changes caused by the command instead of running the command directly. But that would be an unreasonable amount of extra work just for a small feature and to make exploits harder.
- OR the server simply disallows clients from running Lua commands, which is the case for some servers.
I don’t get the second part though: why a map can store arbitrary Lua code that runs when the map loads.