Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
Basic Lehmer RNG implementation using closures
--lua 5.3 local function lehmer(s) local seed if s == nil then seed = os.time() else seed = assert(tonumber(s), "seed is not a number") assert(s == s and s ~= math.huge, "seed cannot be nan or inf") seed = math.fmod(math.floor(s), 2^31-1) if seed <= 0 then seed = seed + 2^31-2 end end return function() seed = math.fmod(seed*16807, 2^31-1) return math.tointeger(seed) -- on Lua 5.1, return seed directly instead end end local rng = lehmer() for _ = 1, 1000 do print(rng()) end
run
|
edit
|
history
|
help
1
PAID HACK PuBG
PAID HACK PuBG
123
test123
multiline string
Key
ShSlotMachine_Data
Creating habits v3, Lua
Conta valores acima da média - LUA
Conta valores acima da média - LUA