Module:Generic Random Picker

From Ways of Darkness
Jump to navigation Jump to search

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

function returner(numb,table)
	local max = #table
	local toreturn = tonumber(numb) % max
	if toreturn == 0 then
		toreturn = max
	end
    return table[toreturn]
end

function RandomPicking(table)
	local rett = { }
	function rett.main(numb)
		return returner(numb,table)
	end
	function rett.rand()
		math.randomseed(os.time())
		return returner(math.rand(#table),table)
	end
	function rett.loop()
		local temp = os.date("*t")
		return returner(temp.yday,table)
	end
	return rett
end