Add more resource information to order view
This commit is contained in:
parent
61d59846ac
commit
488561fab5
27
orders.lua
27
orders.lua
|
@ -9,13 +9,22 @@ local function fetch(wait_for)
|
||||||
local colony_orders = colony.getWorkOrders()
|
local colony_orders = colony.getWorkOrders()
|
||||||
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 resources = colony.getWorkOrderResources(wo.id)
|
||||||
if res == nil then
|
local res_status = "?/?/0"
|
||||||
res = "0"
|
if resources ~= nil then
|
||||||
else
|
local unavailable_count = 0
|
||||||
res = "" .. #res
|
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
|
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)
|
wait_for(config.step_sleep_time)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -45,9 +54,9 @@ local function display(page_start_idx)
|
||||||
term.write(val.target)
|
term.write(val.target)
|
||||||
term.write(" ")
|
term.write(" ")
|
||||||
end
|
end
|
||||||
if val.res_count then
|
if val.res_status then
|
||||||
term.setCursorPos(tw-2-#val.res_count, line_num)
|
term.setCursorPos(tw-2-#val.res_status, line_num)
|
||||||
term.write(val.res_count)
|
term.write(val.res_status)
|
||||||
else
|
else
|
||||||
term.setCursorPos(tw-2, line_num)
|
term.setCursorPos(tw-2, line_num)
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue