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 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 pairs(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_status=res_status, claimed=wo.isClaimed}) wait_for(config.step_sleep_time) end end end local function displayTab(self) self.window.clear() local tw,th = self.window.getSize() for i, val in pairs(orders) do local line_num = (i-self.scrollPos)*2+1 if line_num > 0 and line_num < th-1 then self.window.setTextColor(colors.lightGray) self.window.setCursorPos(1,line_num) self.window.write(val.id) self.window.write(" ") if val.pos then self.window.write(val.pos.x .. "," .. val.pos.y .. "," .. val.pos.z) self.window.write(" ") end self.window.setCursorPos(2,line_num+1) self.window.setTextColor(colors.white) if val.type then self.window.write(val.type) self.window.write(" ") end if val.target then self.window.write(val.target) self.window.write(" ") end if val.res_status then self.window.setCursorPos(tw-2-#val.res_status, line_num) self.window.write(val.res_status) else self.window.setCursorPos(tw-2, line_num) end self.window.write(" ") if val.claimed then self.window.setTextColor(colors.yellow) self.window.write("C") self.window.setTextColor(colors.white) else self.window.write(" ") end self.window.write(" ") end end end local function onTouch(self, touch_x, touch_y) return false end return { name="orders", fetch=fetch, displayTab=displayTab, onTouch=onTouch, }