Toggle menu
Toggle personal menu
Not logged in
Your IP address will be publicly visible if you make any edits.

Module:Random

From ProleWiki, the proletarian encyclopedia
Revision as of 23:43, 5 October 2022 by Forte (talk | contribs) (Attempt to improve random number generator)
local p = {}

function p.random(frame)
	local parent = frame:getParent()
	
	local a = tonumber(parent.args[1]) or 1
	local b = tonumber(parent.args[2]) or 100
	
	local Date = os.date()
	local h = Date:match("(%d+):%d+:%d+")
	local m = Date:match("%d+:(%d+):%d+")
	local s = Date:match("%d+:%d+:(%d+)")
	local rnd = s * s * math.random(1,10000)
	
	while (rnd > b) do
		rnd = math.floor(rnd/b)
	end
	while (rnd < a) do
		rnd = math.floor(rnd*1.5)
	end
	return rnd
end
return p