Desyncs
Wed, 2024-01-03 20:57
Hi , i made a kaos mod (first mod ive made) but it keeps desyncing on round 2 when i play with other people , do i have to do anything else for it to work?
Hi , i made a kaos mod (first mod ive made) but it keeps desyncing on round 2 when i play with other people , do i have to do anything else for it to work?
figured it out, lua's random wouldnt work
Yes, indeed. Using math.random for gameplay-related events like setting the position of a hedgehog is strictly forbidden!
The reason for that is because math.random isn't synchronized between the clients and each client might generate different random numbers, thus causing clients to end up in a different state so they're no longer synchronized and the game must fail for that reason.
That doesn't mean you can't use math.random ever. For things that don't affect gameplay, like purely graphical effects, math.random is safe.
I just noticed the HWKB page for Lua code rules didn't mention math.random so far, so I added it right now. (math.random was only mentioned at the GetRandom function documentation so this could have been overlooked easily)
LuaRules
Hi, I am a Hedgewars developer.