Add more resource information to order view

This commit is contained in:
Ben 2024-06-01 04:48:39 +02:00
parent 61d59846ac
commit 488561fab5
Signed by: ben
GPG key ID: 1353F41CF1CFF2D3

View file

@ -9,13 +9,22 @@ local function fetch(wait_for)
local colony_orders = colony.getWorkOrders()
if colony_orders ~= nil then
for i, wo in pairs(colony_orders) do
local res = colony.getWorkOrderResources(wo.id)
if res == nil then
res = "0"
else
res = "" .. #res
local resources = colony.getWorkOrderResources(wo.id)
local res_status = "?/?/0"
if resources ~= nil then
local unavailable_count = 0
local deliver_count = 0
for j, res in resources do
if not res.available then
unavailable_count = unavailable_count + 1
end
if res.delivering then
deliver_count = deliver_count + 1
end
end
res_status = unavailable_count .. "/" .. deliver_count .. "/" .. #resources
end
table.insert(orders, {id=wo.id, type=wo.workOrderType, target=wo.type, pos=wo.builder, res_count=res, claimed=wo.isClaimed})
table.insert(orders, {id=wo.id, type=wo.workOrderType, target=wo.type, pos=wo.builder, res_status=res_status, claimed=wo.isClaimed})
wait_for(config.step_sleep_time)
end
end
@ -45,9 +54,9 @@ local function display(page_start_idx)
term.write(val.target)
term.write(" ")
end
if val.res_count then
term.setCursorPos(tw-2-#val.res_count, line_num)
term.write(val.res_count)
if val.res_status then
term.setCursorPos(tw-2-#val.res_status, line_num)
term.write(val.res_status)
else
term.setCursorPos(tw-2, line_num)
end