From a645d7b3109270242e686b5d9eb86f295fbe6107 Mon Sep 17 00:00:00 2001 From: Benedikt Ziemons Date: Tue, 4 Jun 2024 01:07:50 +0200 Subject: [PATCH] Use work order for inspection --- inspect.lua | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/inspect.lua b/inspect.lua index c9453d0..5319f33 100644 --- a/inspect.lua +++ b/inspect.lua @@ -1,3 +1,4 @@ +local config = require "config" local winhlp = require "winhlp" local function drawLine(termlike, pair) @@ -11,23 +12,31 @@ local function drawLine(termlike, pair) termlike.write(string.format("%" .. padding+1 .. "s", " ")) termlike.write(value) end - local listview = (require "listview"):new{drawEntry=drawLine} -local keys = {[1]="a", [2]="c"} -local obj = {a="b", c="d"} - local function setTerm(termlike) listview.frame = termlike end -local function setObject(other) - obj = other - keys = {} +local function prepareObject(other) + local keys = {} for key, _ in other do keys.insert(key) end table.sort(keys) + return other, keys +end + +local obj = {} +local keys = {} + +local colony = peripheral.wrap(config.colony_interface_side) +if colony.isInColony() then + obj, keys = prepareObject{colony.getWorkOrders()[1]} +end + +local function setObject(other) + obj, keys = prepareObject{other} end local function fetch(wait_for)