Effects, random numbers, and desyncs

Place to get help with not working mods / modding interface.
Post Reply
danielbrauer
Long Handed Inserter
Long Handed Inserter
Posts: 93
Joined: Thu May 18, 2017 2:22 pm
Contact:

Effects, random numbers, and desyncs

Post 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.

orzelek
Smart Inserter
Smart Inserter
Posts: 3911
Joined: Fri Apr 03, 2015 10:20 am
Contact:

Re: Effects, random numbers, and desyncs

Post 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.

Bilka
Factorio Staff
Factorio Staff
Posts: 3132
Joined: Sat Aug 13, 2016 9:20 am
Contact:

Re: Effects, random numbers, and desyncs

Post 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.
I'm an admin over at https://wiki.factorio.com. Feel free to contact me if there's anything wrong (or right) with it.

danielbrauer
Long Handed Inserter
Long Handed Inserter
Posts: 93
Joined: Thu May 18, 2017 2:22 pm
Contact:

Re: Effects, random numbers, and desyncs

Post by danielbrauer »

Ok that makes sense, and makes things really easy. Thanks!

Post Reply

Return to “Modding help”