Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local monitor = peripheral.find("monitor")
- local display = monitor or term
- if monitor then monitor.setTextScale(0.5) end
- local w, h = display.getSize()
- local buffer = window.create(display, 1, 1, w, h, false)
- local function getPower(p)
- if not p then return 0, 1 end
- local e = (p.getEnergy and p.getEnergy()) or (p.getEnergyStored and p.getEnergyStored()) or 0
- local m = (p.getEnergyCapacity and p.getEnergyCapacity()) or (p.getMaxEnergyStored and p.getMaxEnergyStored()) or 1
- return e, m
- end
- local function formatNum(n)
- if not n then return "0" end
- if n >= 1e6 then return string.format("%.2fM", n / 1e6)
- elseif n >= 1e3 then return string.format("%.1fk", n / 1e3)
- else return tostring(math.floor(n)) end
- end
- local function drawBar(x, y, width, pct, fColor, bColor)
- buffer.setCursorPos(x, y)
- local fill = math.floor((math.min(100, math.max(0, pct)) / 100) * width)
- buffer.setTextColor(fColor)
- buffer.write(string.rep("|", fill))
- buffer.setTextColor(bColor)
- buffer.write(string.rep("-", width - fill))
- end
- while true do
- local chambers = { peripheral.find("hostilenetworks:sim_chamber") }
- local dcIO = peripheral.find("hostilenetworks:data_center_io_port")
- local dcController = peripheral.find("hostilenetworks:data_center")
- buffer.setVisible(false)
- buffer.setBackgroundColor(colors.black)
- buffer.clear()
- buffer.setCursorPos(1, 1)
- buffer.setTextColor(colors.cyan)
- buffer.write("=== HNN ACTIVE LOGISTICS DASHBOARD ===")
- local y = 3
- -- ==========================================
- -- 1. DATA CENTER TELEMETRY
- -- ==========================================
- buffer.setCursorPos(1, y)
- buffer.setTextColor(colors.yellow)
- buffer.write("[ Data Center Mainframe ]")
- buffer.setCursorPos(3, y + 1)
- buffer.setTextColor(colors.lightGray)
- buffer.write("Models: ")
- if dcController and dcController.size then
- local dcModels = {}
- for slot = 1, dcController.size() do
- local item = dcController.getItemDetail(slot)
- if item and item.name:find("data_model") then
- table.insert(dcModels, item.displayName:gsub(" Data Model", ""))
- end
- end
- buffer.setTextColor(#dcModels > 0 and colors.cyan or colors.red)
- buffer.write(#dcModels > 0 and table.concat(dcModels, ", ") or "Empty")
- else
- buffer.setTextColor(colors.red)
- buffer.write("MODEM MISSING ON CONTROLLER BLOCK")
- end
- local matCount, outCount = 0, 0
- if dcIO then
- for _, item in pairs(dcIO.list() or {}) do
- if item.name:find("prediction_matrix") then matCount = matCount + item.count
- else outCount = outCount + item.count end
- end
- end
- buffer.setCursorPos(3, y + 2)
- buffer.setTextColor(colors.lightGray)
- buffer.write("IO Buffer: ")
- buffer.setTextColor(matCount > 0 and colors.green or colors.yellow)
- buffer.write(tostring(matCount) .. " Matrices In")
- buffer.setTextColor(colors.lightGray)
- buffer.write(" | ")
- buffer.setTextColor(colors.purple)
- buffer.write(tostring(outCount) .. " Drops Out")
- local dcE, dcM = getPower(dcController or dcIO)
- local dcPct = math.floor((dcE/dcM)*100)
- buffer.setCursorPos(3, y + 3)
- buffer.setTextColor(colors.lightGray)
- buffer.write("Power: ")
- drawBar(14, y + 3, 10, dcPct, colors.green, colors.gray)
- buffer.setTextColor(colors.white)
- buffer.write(string.format(" %s FE (%d%%)", formatNum(dcE), dcPct))
- y = y + 5
- -- ==========================================
- -- 2. SIMULATION CHAMBER ACTIVE TRACKING
- -- ==========================================
- for i, c in ipairs(chambers) do
- local cName = peripheral.getName(c)
- local model = c.getItemDetail(1)
- local targetName = model and model.displayName and model.displayName:gsub(" Data Model", "") or "Empty"
- local currentMat = c.getItemDetail(2)
- local matCountSlot = currentMat and currentMat.count or 0
- -- ACTIVE LOGISTICS EXTRACTION
- if dcIO and targetName ~= "Empty" then
- -- Silently extract all items to the IO Port so the machine never jams
- dcIO.pullItems(cName, 3, 64)
- dcIO.pullItems(cName, 4, 64)
- end
- -- Render Chamber UI
- buffer.setCursorPos(1, y)
- buffer.setTextColor(colors.yellow)
- buffer.write(string.format("[ Sim Chamber %d ]", i))
- buffer.setCursorPos(3, y + 1)
- buffer.setTextColor(colors.lightGray)
- buffer.write("Target: ")
- buffer.setTextColor(colors.cyan)
- buffer.write(targetName)
- buffer.setCursorPos(3, y + 2)
- buffer.setTextColor(colors.lightGray)
- buffer.write("Input: ")
- if matCountSlot > 0 then
- buffer.setTextColor(matCountSlot < 8 and colors.yellow or colors.green)
- buffer.write(string.format("%d Matrices", matCountSlot))
- else
- buffer.setTextColor(colors.red)
- buffer.write("0 Matrices (HALTED)")
- end
- local gen = c.getItemDetail(4)
- buffer.setCursorPos(3, y + 3)
- buffer.setTextColor(colors.lightGray)
- buffer.write("Output: ")
- if gen then
- buffer.setTextColor(colors.purple)
- buffer.write(string.format("%d Generalized", gen.count))
- else
- buffer.setTextColor(colors.gray)
- buffer.write("Extracted to IO Port")
- end
- local e, m = getPower(c)
- local pct = math.floor((e/m)*100)
- buffer.setCursorPos(3, y + 4)
- buffer.setTextColor(colors.lightGray)
- buffer.write("Power: ")
- drawBar(11, y + 4, 10, pct, colors.green, colors.gray)
- buffer.setTextColor(colors.white)
- buffer.write(string.format(" %s FE (%d%%)", formatNum(e), pct))
- y = y + 6
- end
- buffer.setVisible(true)
- sleep(0.5)
- end
Advertisement