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

Module:Test2: Difference between revisions

From ProleWiki, the proletarian encyclopedia
m (Accepting arguments)
m (Using time in seconds of the os to generate more randomness)
Line 2: Line 2:


function p.randomNumber(frame)
function p.randomNumber(frame)
local seed = tostring(os.time()):reverse():sub(1,5)
math.randomseed(seed)
local min = tonumber(frame.args[1]) or 0
local min = tonumber(frame.args[1]) or 0
local max = tonumber(frame.args[2]) or 100
local max = tonumber(frame.args[2]) or 100

Revision as of 01:33, 18 February 2023

local p = {}

function p.randomNumber(frame)
	local seed = tostring(os.time()):reverse():sub(1,5)
	math.randomseed(seed)
	local min = tonumber(frame.args[1]) or 0
	local max = tonumber(frame.args[2]) or 100
	return math.random(min, max)
end

return p