Fix error accessing work order resources

This commit is contained in:
Ben 2024-06-01 03:43:35 +02:00
parent b575517317
commit 76663b9371
Signed by: ben
GPG key ID: 1353F41CF1CFF2D3

View file

@ -83,13 +83,13 @@ function ordersDisplay()
term.write(val.target) term.write(val.target)
term.write(" ") term.write(" ")
end end
if val.item then if val.res_count then
term.setCursorPos(tw-6-#val.item, line_num) term.setCursorPos(tw-2-#val.res_count, line_num)
term.write(val.item) term.write(val.res_count)
else else
term.setCursorPos(tw-6, line_num) term.setCursorPos(tw-2, line_num)
end end
term.write(" ") term.write(" ")
if val.claimed then if val.claimed then
term.setTextColor(colors.yellow) term.setTextColor(colors.yellow)
term.write("C") term.write("C")
@ -98,14 +98,6 @@ function ordersDisplay()
term.write(" ") term.write(" ")
end end
term.write(" ") term.write(" ")
if val.delivering then
term.setTextColor(colors.green)
term.write("D")
term.setTextColor(colors.white)
else
term.write(" ")
end
term.write(" ")
end end
end end
end end
@ -259,7 +251,12 @@ function get_orders()
if colony_orders ~= nil then if colony_orders ~= nil then
for i, wo in pairs(colony_orders) do for i, wo in pairs(colony_orders) do
local res = colony.getWorkOrderResources(wo.id) local res = colony.getWorkOrderResources(wo.id)
table.insert(orders, {id=wo.id, type=wo.workOrderType, target=wo.type, pos=wo.builder, resources=res, claimed=wo.isClaimed, delivering=res.delivering}) if res == nil then
res = "0"
else
res = "" .. #res
end
table.insert(orders, {id=wo.id, type=wo.workOrderType, target=wo.type, pos=wo.builder, res_count=res, claimed=wo.isClaimed})
wait_for(config.step_sleep_time) wait_for(config.step_sleep_time)
end end
end end