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)