Forgottenserver: math.random on startup

Created on 12 Nov 2015  路  5Comments  路  Source: otland/forgottenserver

local x = math.random(5)
print(x)
when i put this in onStartup() (globalevents/startup.lua), always results 3.
when i put "math.random(10)", always results 6.
this is a bug?

bug

All 5 comments

Have you tried setting the seed before using math.random()?

math.randomseed(os.time())

it worked, thanks!

Only one doubt, what is the purpose of this random?
Thank you =)

Every time you start the server the random seed would be different so the random numbers aren't always the same. That's what happens when you choose time as the random seed. It's for increasing unpredictability.

Thank you @Tarliton =)

Was this page helpful?
0 / 5 - 0 ratings

Related issues

TwistedScorpio picture TwistedScorpio  路  5Comments

GoularPink picture GoularPink  路  3Comments

EPuncker picture EPuncker  路  4Comments

MillhioreBT picture MillhioreBT  路  4Comments

GoularPink picture GoularPink  路  4Comments