Unsure of what's wrong here, non-executable and it seems to expect } near the ='s and some form of expression following. it's just a weighttable for generation of items.
See:
function decide (weighttable)
local weighttotal = 0
local weightranges = {}
for z,p in pairs
do table.insert(weightranges,{Item = z.Min = weighttotal,+1Max = weighttotal + p})
end
local match = nil
if weighttoal >0 then
local num =
math.random(1,weighttotal)
for _,p in pairs(weightranges) do if num >p.Min and num < p.Max or num == p.Min or num == p.Max then
match = p.Item
end
end
end
return match
end
(I have a separate table with weight values.)
See:
function decide (weighttable)
local weighttotal = 0
local weightranges = {}
for z,p in pairs
do table.insert(weightranges,{Item = z.Min = weighttotal,+1Max = weighttotal + p})
end
local match = nil
if weighttoal >0 then
local num =
math.random(1,weighttotal)
for _,p in pairs(weightranges) do if num >p.Min and num < p.Max or num == p.Min or num == p.Max then
match = p.Item
end
end
end
return match
end
(I have a separate table with weight values.)