Use work order for inspection
This commit is contained in:
parent
08122f1f7e
commit
a645d7b310
23
inspect.lua
23
inspect.lua
|
@ -1,3 +1,4 @@
|
||||||
|
local config = require "config"
|
||||||
local winhlp = require "winhlp"
|
local winhlp = require "winhlp"
|
||||||
|
|
||||||
local function drawLine(termlike, pair)
|
local function drawLine(termlike, pair)
|
||||||
|
@ -11,23 +12,31 @@ local function drawLine(termlike, pair)
|
||||||
termlike.write(string.format("%" .. padding+1 .. "s", " "))
|
termlike.write(string.format("%" .. padding+1 .. "s", " "))
|
||||||
termlike.write(value)
|
termlike.write(value)
|
||||||
end
|
end
|
||||||
|
|
||||||
local listview = (require "listview"):new{drawEntry=drawLine}
|
local listview = (require "listview"):new{drawEntry=drawLine}
|
||||||
|
|
||||||
local keys = {[1]="a", [2]="c"}
|
|
||||||
local obj = {a="b", c="d"}
|
|
||||||
|
|
||||||
local function setTerm(termlike)
|
local function setTerm(termlike)
|
||||||
listview.frame = termlike
|
listview.frame = termlike
|
||||||
end
|
end
|
||||||
|
|
||||||
local function setObject(other)
|
local function prepareObject(other)
|
||||||
obj = other
|
local keys = {}
|
||||||
keys = {}
|
|
||||||
for key, _ in other do
|
for key, _ in other do
|
||||||
keys.insert(key)
|
keys.insert(key)
|
||||||
end
|
end
|
||||||
table.sort(keys)
|
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
|
end
|
||||||
|
|
||||||
local function fetch(wait_for)
|
local function fetch(wait_for)
|
||||||
|
|
Loading…
Reference in a new issue