Page 1 of 1

Effects, random numbers, and desyncs

Posted: Fri Apr 12, 2019 10:20 pm
by danielbrauer
Are effects rendered using rendering.draw_animation() and rendering.draw_light() expected to be synchronised?

If not, how do I synchronise the state of a random number generator? As far as I can see, Lua's math.random() only lets you seed it, but there's no facility for synchronising state.

Re: Effects, random numbers, and desyncs

Posted: Sat Apr 13, 2019 12:13 am
by orzelek
Take a look here:
https://lua-api.factorio.com/latest/Lua ... rator.html

Also if I recall correctly you don't need to sync math.random(). It is modified for game use and uses map random generator.

Re: Effects, random numbers, and desyncs

Posted: Sat Apr 13, 2019 7:07 am
by Bilka
Render objects are part of the game state, just like entities. If they weren't, they'd be disappearing on save load :lol:

Math random is deterministic and math randomseed it does nothing.

Re: Effects, random numbers, and desyncs

Posted: Sat Apr 13, 2019 9:08 am
by danielbrauer
Ok that makes sense, and makes things really easy. Thanks!