local find_coal = function()
local stock = {}
- local total = 0
- local min = false
- for addr,barrel in pairs(coal_barrels) do
+ for addr, barrel in pairs(coal_barrels) do
local item = barrel.getItemDetail(1)
local amt = item and item.count or 0
stock[addr] = amt
- total = total + amt
- end
- -- this is shite code, deal with it
- local avg = total/2
- for addr,barrel in pairs(coal_barrels) do
- if stock[addr] > avg then
-
end
return stock
end
local fullest_coal_barrel = function(stock)
local r = { addr = false, count = 0 }
for barrel_addr, count in pairs(stock) do
- if count >= fullest_coal_barrel.count then
+ if count >= r.count then
r = { addr = barrel_addr, count = count }
end
end