58 lines
1.4 KiB
Lua
58 lines
1.4 KiB
Lua
-- script for monitoring Build Resources
|
|
require("printTable")
|
|
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.setCursorBlink(false)
|
|
monitor.setTextScale(1.0)
|
|
monitor.clear()
|
|
monitor.setCursorPos(1, 1)
|
|
end
|
|
|
|
local function tFilter(t, func)
|
|
local result = {}
|
|
for key, value in pairs(t) do
|
|
if func(value) then
|
|
table.insert(result, value)
|
|
end
|
|
end
|
|
return result
|
|
end
|
|
|
|
local function printBuRes()
|
|
for name, list in pairs(buRes) do
|
|
term.setTextColor(colors.black)
|
|
term.setBackgroundColor(colors.white)
|
|
print(name)
|
|
term.setTextColor(colors.white)
|
|
term.setBackgroundColor(colors.black)
|
|
for key, value in pairs(list) do
|
|
print(value.item.displayName, value.available .. "+" .. value.delivering .. "/" .. value.item.count)
|
|
end
|
|
end
|
|
end
|
|
|
|
local function bures()
|
|
local count = 0
|
|
for key, value in pairs(buildings) do
|
|
count = count + 1
|
|
local name = value.name
|
|
if name == "" then
|
|
name = "Builder " .. tostring(count)
|
|
end
|
|
buRes[name] = colony.getBuilderResources(value.location)
|
|
end
|
|
end
|
|
|
|
clearMonitor()
|
|
buildings = tFilter(buildings, function(value) return value.type == "builder" end)
|
|
bures()
|
|
printBuRes()
|