Lua in SpringRTS/Synced Mode

From Wikibooks, open books for an open world
Jump to navigation Jump to search

Synced mode is the environment that all players share. Code that is run in synced mode is run practically by all players thus all players must get the same results from the code execution. That's the reason that some of the usual Lua code is not allowed like for example the math.randomseed() as that would give different random values for each player which is not acceptable.
It's worth mentioning that Widgets are never allowed to execute synced code as that would imply cheating. Gadgets on the other hand are allowed to run both synced and unsynced code but in a special manner.

Synced code should practically hold callins[check spelling] that change the same things for all players.