Juge-Gabranth

Untitled

Aug 26th, 2026 (edited)
27,722
1
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.97 KB | None | 1 0
  1. local monitor = peripheral.find("monitor")
  2. local display = monitor or term
  3. if monitor then monitor.setTextScale(0.5) end
  4.  
  5. local w, h = display.getSize()
  6. local buffer = window.create(display, 1, 1, w, h, false)
  7.  
  8. local function getPower(p)
  9. if not p then return 0, 1 end
  10. local e = (p.getEnergy and p.getEnergy()) or (p.getEnergyStored and p.getEnergyStored()) or 0
  11. local m = (p.getEnergyCapacity and p.getEnergyCapacity()) or (p.getMaxEnergyStored and p.getMaxEnergyStored()) or 1
  12. return e, m
  13. end
  14.  
  15. local function formatNum(n)
  16. if not n then return "0" end
  17. if n >= 1e6 then return string.format("%.2fM", n / 1e6)
  18. elseif n >= 1e3 then return string.format("%.1fk", n / 1e3)
  19. else return tostring(math.floor(n)) end
  20. end
  21.  
  22. local function drawBar(x, y, width, pct, fColor, bColor)
  23. buffer.setCursorPos(x, y)
  24. local fill = math.floor((math.min(100, math.max(0, pct)) / 100) * width)
  25. buffer.setTextColor(fColor)
  26. buffer.write(string.rep("|", fill))
  27. buffer.setTextColor(bColor)
  28. buffer.write(string.rep("-", width - fill))
  29. end
  30.  
  31. while true do
  32. local chambers = { peripheral.find("hostilenetworks:sim_chamber") }
  33. local dcIO = peripheral.find("hostilenetworks:data_center_io_port")
  34. local dcController = peripheral.find("hostilenetworks:data_center")
  35.  
  36. buffer.setVisible(false)
  37. buffer.setBackgroundColor(colors.black)
  38. buffer.clear()
  39.  
  40. buffer.setCursorPos(1, 1)
  41. buffer.setTextColor(colors.cyan)
  42. buffer.write("=== HNN ACTIVE LOGISTICS DASHBOARD ===")
  43.  
  44. local y = 3
  45.  
  46. -- ==========================================
  47. -- 1. DATA CENTER TELEMETRY
  48. -- ==========================================
  49. buffer.setCursorPos(1, y)
  50. buffer.setTextColor(colors.yellow)
  51. buffer.write("[ Data Center Mainframe ]")
  52.  
  53. buffer.setCursorPos(3, y + 1)
  54. buffer.setTextColor(colors.lightGray)
  55. buffer.write("Models: ")
  56. if dcController and dcController.size then
  57. local dcModels = {}
  58. for slot = 1, dcController.size() do
  59. local item = dcController.getItemDetail(slot)
  60. if item and item.name:find("data_model") then
  61. table.insert(dcModels, item.displayName:gsub(" Data Model", ""))
  62. end
  63. end
  64. buffer.setTextColor(#dcModels > 0 and colors.cyan or colors.red)
  65. buffer.write(#dcModels > 0 and table.concat(dcModels, ", ") or "Empty")
  66. else
  67. buffer.setTextColor(colors.red)
  68. buffer.write("MODEM MISSING ON CONTROLLER BLOCK")
  69. end
  70.  
  71. local matCount, outCount = 0, 0
  72. if dcIO then
  73. for _, item in pairs(dcIO.list() or {}) do
  74. if item.name:find("prediction_matrix") then matCount = matCount + item.count
  75. else outCount = outCount + item.count end
  76. end
  77. end
  78.  
  79. buffer.setCursorPos(3, y + 2)
  80. buffer.setTextColor(colors.lightGray)
  81. buffer.write("IO Buffer: ")
  82. buffer.setTextColor(matCount > 0 and colors.green or colors.yellow)
  83. buffer.write(tostring(matCount) .. " Matrices In")
  84. buffer.setTextColor(colors.lightGray)
  85. buffer.write(" | ")
  86. buffer.setTextColor(colors.purple)
  87. buffer.write(tostring(outCount) .. " Drops Out")
  88.  
  89. local dcE, dcM = getPower(dcController or dcIO)
  90. local dcPct = math.floor((dcE/dcM)*100)
  91. buffer.setCursorPos(3, y + 3)
  92. buffer.setTextColor(colors.lightGray)
  93. buffer.write("Power: ")
  94. drawBar(14, y + 3, 10, dcPct, colors.green, colors.gray)
  95. buffer.setTextColor(colors.white)
  96. buffer.write(string.format(" %s FE (%d%%)", formatNum(dcE), dcPct))
  97.  
  98. y = y + 5
  99.  
  100. -- ==========================================
  101. -- 2. SIMULATION CHAMBER ACTIVE TRACKING
  102. -- ==========================================
  103. for i, c in ipairs(chambers) do
  104. local cName = peripheral.getName(c)
  105. local model = c.getItemDetail(1)
  106. local targetName = model and model.displayName and model.displayName:gsub(" Data Model", "") or "Empty"
  107.  
  108. local currentMat = c.getItemDetail(2)
  109. local matCountSlot = currentMat and currentMat.count or 0
  110.  
  111. -- ACTIVE LOGISTICS EXTRACTION
  112. if dcIO and targetName ~= "Empty" then
  113. -- Silently extract all items to the IO Port so the machine never jams
  114. dcIO.pullItems(cName, 3, 64)
  115. dcIO.pullItems(cName, 4, 64)
  116. end
  117.  
  118. -- Render Chamber UI
  119. buffer.setCursorPos(1, y)
  120. buffer.setTextColor(colors.yellow)
  121. buffer.write(string.format("[ Sim Chamber %d ]", i))
  122.  
  123. buffer.setCursorPos(3, y + 1)
  124. buffer.setTextColor(colors.lightGray)
  125. buffer.write("Target: ")
  126. buffer.setTextColor(colors.cyan)
  127. buffer.write(targetName)
  128.  
  129. buffer.setCursorPos(3, y + 2)
  130. buffer.setTextColor(colors.lightGray)
  131. buffer.write("Input: ")
  132. if matCountSlot > 0 then
  133. buffer.setTextColor(matCountSlot < 8 and colors.yellow or colors.green)
  134. buffer.write(string.format("%d Matrices", matCountSlot))
  135. else
  136. buffer.setTextColor(colors.red)
  137. buffer.write("0 Matrices (HALTED)")
  138. end
  139.  
  140. local gen = c.getItemDetail(4)
  141. buffer.setCursorPos(3, y + 3)
  142. buffer.setTextColor(colors.lightGray)
  143. buffer.write("Output: ")
  144. if gen then
  145. buffer.setTextColor(colors.purple)
  146. buffer.write(string.format("%d Generalized", gen.count))
  147. else
  148. buffer.setTextColor(colors.gray)
  149. buffer.write("Extracted to IO Port")
  150. end
  151.  
  152. local e, m = getPower(c)
  153. local pct = math.floor((e/m)*100)
  154. buffer.setCursorPos(3, y + 4)
  155. buffer.setTextColor(colors.lightGray)
  156. buffer.write("Power: ")
  157. drawBar(11, y + 4, 10, pct, colors.green, colors.gray)
  158. buffer.setTextColor(colors.white)
  159. buffer.write(string.format(" %s FE (%d%%)", formatNum(e), pct))
  160.  
  161. y = y + 6
  162. end
  163.  
  164. buffer.setVisible(true)
  165. sleep(0.5)
  166. end
Advertisement