for _, good in pairs(soldgoods)
do
-- Don't bother doing anything if there isn't anything to actually sell
local numGoods
local maxgoods
local priority
--retval, numGoods = station:invokeFunction(stationscript, "getNumGoods", good)
retval, numGoods, maxgoods = station:invokeFunction(stationscript, "getStock", good)
-- debug_msg(station.name .. " is selling " .. numGoods .. " " .. good)
if (retval == 0 and numGoods > 1000)
then
if maxgoods > 0 then
priority = numGoods / maxgoods
else
priority = 0
end
if (haulGoodsList[good]) -- Already initialized?
then
table.insert(haulGoodsList[good]["from"], station)
if priority > haulGoodsList[good]["fpriority"] then
haulGoodsList[good]["fpriority"] = priority
end
else -- Initialize good
haulGoodsList[good] = {from = {station}, to = {}, amount = numGoods, fpriority = priority, tpriority = 0, priority = 0}
end
end
end