Module:Random

From ProleWiki, the proletarian encyclopedia
Revision as of 00:05, 6 October 2022 by Forte (talk | contribs)
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 = math.random(1,10000) * h * m * s
	
	while (rnd > b) do
		rnd = math.floor(rnd/b)
	end
	while (rnd < a) do
		if (rnd == 0) then
			rnd = b/a
		end
		rnd = math.floor(rnd*1.76)
		if (rnd > b) then
			rnd = math.random(a,b)
		end
	end
	return rnd
end
return p