From 488561fab595c387333800d278452502acd832c0 Mon Sep 17 00:00:00 2001 From: Benedikt Ziemons Date: Sat, 1 Jun 2024 04:48:39 +0200 Subject: [PATCH] Add more resource information to order view --- orders.lua | 27 ++++++++++++++++++--------- 1 file changed, 18 insertions(+), 9 deletions(-) diff --git a/orders.lua b/orders.lua index bf5f651..a19d00b 100644 --- a/orders.lua +++ b/orders.lua @@ -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