Jump to: navigation, search

Module:Random

Revision as of 12:10, 11 May 2017 by CraftSpider (talk | contribs) (Created module dependency)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Documentation for this module may be created at Module:Random/doc

local p = {}
local seeded
local randomseed = math.randomseed
local random = math.random

function p.random( m, n )
	if not seeded then
		p.seed()
	end
	
	return random( n and m or m and 1 or 0, n or m or 1 )
end

function p.seed( seed )
	randomseed( seed or ( os.time() + os.clock() * 1000000000 ) )
	
	-- First few values of seed is not guaranteed to be random on some platforms
	random()
	random()
	
	seeded = true
end

return p


Cookies help us deliver our services. By using our services, you agree to our use of cookies.