2024-06-01 02:39:41 +00:00
|
|
|
local config = require "config"
|
|
|
|
|
|
|
|
local colony = peripheral.wrap(config.colony_interface_side)
|
|
|
|
local orders = {}
|
|
|
|
|
|
|
|
|
|
|
|
local function fetch(wait_for)
|
|
|
|
orders = {}
|
|
|
|
local colony_orders = colony.getWorkOrders()
|
|
|
|
if colony_orders ~= nil then
|
|
|
|
for i, wo in pairs(colony_orders) do
|
2024-06-01 02:48:39 +00:00
|
|
|
local resources = colony.getWorkOrderResources(wo.id)
|
|
|
|
local res_status = "?/?/0"
|
|
|
|
if resources ~= nil then
|
|
|
|
local unavailable_count = 0
|
|
|
|
local deliver_count = 0
|
2024-06-01 02:50:08 +00:00
|
|
|
for j, res in pairs(resources) do
|
2024-06-01 02:48:39 +00:00
|
|
|
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
|
2024-06-01 02:39:41 +00:00
|
|
|
end
|
2024-06-01 02:48:39 +00:00
|
|
|
table.insert(orders, {id=wo.id, type=wo.workOrderType, target=wo.type, pos=wo.builder, res_status=res_status, claimed=wo.isClaimed})
|
2024-06-01 02:39:41 +00:00
|
|
|
wait_for(config.step_sleep_time)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
2024-06-01 14:20:00 +00:00
|
|
|
local function displayTab(self)
|
2024-06-01 14:53:51 +00:00
|
|
|
self.window.clear()
|
2024-06-01 14:20:00 +00:00
|
|
|
local tw,th = self.window.getSize()
|
2024-06-01 02:39:41 +00:00
|
|
|
for i, val in pairs(orders) do
|
2024-06-01 14:20:00 +00:00
|
|
|
local line_num = (i-self.scrollPos)*2+1
|
2024-06-01 14:45:34 +00:00
|
|
|
if line_num > 0 and line_num < th-1 then
|
2024-06-01 14:20:00 +00:00
|
|
|
self.window.setTextColor(colors.lightGray)
|
|
|
|
self.window.setCursorPos(1,line_num)
|
|
|
|
self.window.write(val.id)
|
|
|
|
self.window.write(" ")
|
2024-06-01 02:39:41 +00:00
|
|
|
if val.pos then
|
2024-06-01 14:20:00 +00:00
|
|
|
self.window.write(val.pos.x .. "," .. val.pos.y .. "," .. val.pos.z)
|
|
|
|
self.window.write(" ")
|
2024-06-01 02:39:41 +00:00
|
|
|
end
|
2024-06-01 14:20:00 +00:00
|
|
|
self.window.setCursorPos(2,line_num+1)
|
|
|
|
self.window.setTextColor(colors.white)
|
2024-06-01 02:39:41 +00:00
|
|
|
if val.type then
|
2024-06-01 14:20:00 +00:00
|
|
|
self.window.write(val.type)
|
|
|
|
self.window.write(" ")
|
2024-06-01 02:39:41 +00:00
|
|
|
end
|
|
|
|
if val.target then
|
2024-06-01 14:20:00 +00:00
|
|
|
self.window.write(val.target)
|
|
|
|
self.window.write(" ")
|
2024-06-01 02:39:41 +00:00
|
|
|
end
|
2024-06-01 02:48:39 +00:00
|
|
|
if val.res_status then
|
2024-06-01 14:20:00 +00:00
|
|
|
self.window.setCursorPos(tw-2-#val.res_status, line_num)
|
|
|
|
self.window.write(val.res_status)
|
2024-06-01 02:39:41 +00:00
|
|
|
else
|
2024-06-01 14:20:00 +00:00
|
|
|
self.window.setCursorPos(tw-2, line_num)
|
2024-06-01 02:39:41 +00:00
|
|
|
end
|
2024-06-01 14:20:00 +00:00
|
|
|
self.window.write(" ")
|
2024-06-01 02:39:41 +00:00
|
|
|
if val.claimed then
|
2024-06-01 14:20:00 +00:00
|
|
|
self.window.setTextColor(colors.yellow)
|
|
|
|
self.window.write("C")
|
|
|
|
self.window.setTextColor(colors.white)
|
2024-06-01 02:39:41 +00:00
|
|
|
else
|
2024-06-01 14:20:00 +00:00
|
|
|
self.window.write(" ")
|
2024-06-01 02:39:41 +00:00
|
|
|
end
|
2024-06-01 14:20:00 +00:00
|
|
|
self.window.write(" ")
|
2024-06-01 02:39:41 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2024-06-01 14:20:00 +00:00
|
|
|
local function onTouch(self, touch_x, touch_y)
|
2024-06-01 02:39:41 +00:00
|
|
|
return false
|
|
|
|
end
|
|
|
|
|
|
|
|
return {
|
|
|
|
name="orders",
|
|
|
|
fetch=fetch,
|
2024-06-01 14:20:00 +00:00
|
|
|
displayTab=displayTab,
|
|
|
|
onTouch=onTouch,
|
2024-06-01 02:39:41 +00:00
|
|
|
}
|