return function(...)local V={...}local U if#V<2 then return V[1]and V[1][1]end local function f()local U=0 for V,f in ipairs(V)do local g=f[2]U=U+g end for V,f in ipairs(V)do local g=f[2]local E=g/U f[2]=E f[3]=g end end local function g()U=rng:NextNumber()end local function E()local f=0 for V,g in ipairs(V)do local E=g[2]f=f+E if U<=f then return g end end end f()g()local j=E()return j[1],U,j[3]end



return function(...)
	--- Variables
	local entrees = {...}
	local roll
	
	--- Needs a minimum of 1 entree
	if #entrees < 2 then
		--_L.Print("Did not provide enough arguments to simulate lottery (>1)", true)
		return (entrees[1] and entrees[1][1])
	end
	
	--- Convert integers into a percentage (int/total)
	local function Init()
		local total = 0
		--
		for _, entree in ipairs(entrees) do
			local float = entree[2]
			total = total + float
		end
		--
		for _, entree in ipairs(entrees) do
			local float = entree[2]
			local percentage = (float / total)
			entree[2] = percentage
			entree[3] = float
		end
	end
	
	--- Pick a random number (0-1)
	local function Roll()
		roll = rng:NextNumber()
	end
	
	--- Pick winner (actual black magic)
	local function Calc()
		local total = 0
		--
		for _, entree in ipairs(entrees) do
			local percentage = entree[2]
			total = total + percentage
			if roll <= total then
				return entree
			end
		end
	end
	
	--- Run
	Init()
	Roll()
	local result = Calc()
	
	--
	return result[1], roll, result[3]
end
