colony monitor

This commit is contained in:
Buduf 2022-06-30 11:47:16 +02:00
parent df308cf365
commit 128798cf22
2 changed files with 9 additions and 8 deletions

View File

@ -4,8 +4,7 @@ for key, monitor in pairs(monitors) do
monitor.setTextScale(0.5)
monitor.clear()
monitor.setCursorPos(1, 1)
--monitor.write("Hello World!")
end
local wo = colony.getWorkOrders()
local pr = textutils.serialise(wo)
printTable(wo, 0)
local s = printTable(wo)
monitors[1].write(s)

View File

@ -1,14 +1,16 @@
local function _printTable(table, s, tabs)
local result = ""
local function _printTable(table, tabs)
for key, value in pairs(table) do
if type(value) == "table" then
_printTable(value, "", tabs + 1)
_printTable(value, tabs + 1)
else
print(string.rep(' ', tabs), key, value)
result = result .. "\n" .. string.rep(" ", tabs) .. key .. ": " .. value
end
end
return s
end
function printTable(table)
return _printTable(table, "", 0)
_printTable(table, 0)
return result
end