bures-monitor v1

This commit is contained in:
Buduf 2022-07-03 12:27:52 +02:00
parent d471077330
commit 4f562c0ba7

View File

@ -1,11 +1,49 @@
-- script for monitoring Build Resources
require("printTable")
local monitors = { peripheral.find("monitor") }
for key, monitor in pairs(monitors) do
if not colony.isValid() then
print("Colony is not valid.")
return
end
local monitor = peripheral.find("monitor")
term.redirect(monitor)
local buildings = colony.getBuildings()
local buRes = {}
local function clearMonitor()
monitor.setTextScale(0.5)
monitor.clear()
monitor.setCursorPos(1, 1)
end
local wo = colony.getBuilderResources()
term.redirect(monitors[1])
printTable(wo)
local function tFilter(table, func)
local result = {}
for key, value in pairs(table) do
if func(value) then
result.insert(result, value)
end
end
return result
end
local function printBuRes()
for name, list in pairs(buRes) do
term.blit(name, colours.black, colours.white)
for key, value in pairs(list) do
print(value.item.displayName, value.available .. "+" .. value.delivering .. "/" .. value.item.count)
end
end
end
local function bures()
for key, value in pairs(buildings) do
local name = value.name
if name == "" then
name = "Builder " .. value.level
end
buRes[name] = colony.getBuilderResources(value.location)
end
end
buildings = tFilter(buildings, function(value) return value.type == "builder" end)
clearMonitor()