Notice: Undefined offset: 828 in /home/maccabit/domains/maccabipedia.co.il/public_html/skins/Metrolook/customize/includes/app-header.php on line 59
יחידה:Random
מתוך מכביפדיה

ניתן ליצור תיעוד על היחידה הזאת בדף יחידה:Random/תיעוד


local p = {} 



function p.number(args)
	-- Gets a random number.
	first = tonumber(args[1])
	second = tonumber(args[2])
	
	math.randomseed(os.time())

	-- This needs to use if statements as math.random won't accept explicit nil values as arguments.
	if first then
		if second then
			if first > second then -- Second number cannot be less than the first, or it causes an error.
				first, second = second, first
			end
			return math.random(first, second)
		else
			return math.random(1, first)
		end
	else
		return math.random()
	end
end


return p