Bhobbert

Better AE viewer

Jan 4th, 2026 (edited)
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 4.73 KB | Gaming | 0 0
  1. local bridge = peripheral.find("me_bridge") or peripheral.find("meBridge")
  2. local monitor = peripheral.find("monitor")
  3.  
  4. if not bridge then error("ME Bridge not found!") end
  5. if not monitor then monitor = term end
  6.  
  7. local w, h = monitor.getSize()
  8. local canvas = window.create(monitor, 1, 1, w, h)
  9.  
  10. -- CONFIGURATION
  11.  
  12. -- Size of External storage
  13. local EXTERNAL_ITEM_GOAL = 782336
  14. local REACTOR_FUEL_NAME = "alltheores:uranium_ingot"
  15. local WATCHLIST = {
  16.     { name = "minecraft:coal", label = "Coal" },
  17.     { name = "ae2:certus_quartz_crystal", label = "Certus Crystal"},
  18.     { name = "mysticalagriculture:certus_quartz_essence", label = "Certus Essence"},
  19.     { name = "ae2:fluix_crystal", label = "Fluix Crystal" },
  20.     { name = "mysticalagriculture:fluix_essence", label= "Fluix Essence" },
  21.     { name = "mekanism:ingot_refined_obsidian", label = "Refined Obsidian" },
  22.     { name = "mysticalagriculture:refined_obsidian_essence", label = "Refined Obsidian Essence" },
  23.     { name = "create:veridium", label = "Veridium" },
  24.     { name = "mysticalagriculture:stone_essence", label = "Stone Essence" },
  25.     { name = "mysticalagriculture:copper_essence", label = "Copper Essence" },
  26.  
  27. }
  28.  
  29. -- Required for your Uranium tracking
  30. local function getCount(itemName)
  31.     local item = bridge.getItem({name = itemName})
  32.     if item then
  33.         -- 1.21.1 uses .count, older versions use .amount
  34.         return item.count or item.amount or 0
  35.     end
  36.     return 0
  37. end
  38.  
  39. local function safe(n1, n2)
  40.     local func = bridge[n1] or bridge[n2]
  41.     if func then return func() end
  42.     return 0
  43. end
  44.  
  45. local function drawBar(y, label, current, max, color)
  46.     max = math.max(1, max or 1)
  47.     local barWidth = w - 14
  48.     local percent = math.max(0, math.min(1, current / max))
  49.     local filled = math.floor(percent * barWidth)
  50.    
  51.     canvas.setCursorPos(2, y)
  52.     canvas.setTextColor(colors.white)
  53.     canvas.write(label)
  54.    
  55.     canvas.setCursorPos(10, y)
  56.     canvas.setBackgroundColor(colors.gray)
  57.     canvas.write(string.rep(" ", barWidth))
  58.    
  59.     canvas.setCursorPos(10, y)
  60.     canvas.setBackgroundColor(color)
  61.     canvas.write(string.rep(" ", filled))
  62.    
  63.     canvas.setBackgroundColor(colors.black)
  64.     canvas.setCursorPos(w - 3, y)
  65.     canvas.setTextColor(colors.yellow)
  66.     canvas.write(math.floor(percent * 100) .. "%")
  67. end
  68.  
  69. while true do
  70.     term.redirect(canvas)
  71.     canvas.setBackgroundColor(colors.black)
  72.     canvas.clear()
  73.    
  74.     -- Main Stats
  75.     local energy = safe("getStoredEnergy", "getEnergyStorage")
  76.     local maxEnergy = safe("getEnergyCapacity", "getMaxEnergyStorage")
  77.     local usedInt = safe("getUsedItemStorage", "getUsedItemDiskStorage")
  78.     local totalInt = safe("getTotalItemStorage", "getMaxItemDiskStorage")
  79.    
  80.     -- Item Tracking
  81.     local uraniumCount = getCount(REACTOR_FUEL_NAME)
  82.    
  83.     -- External Storage Logic
  84.     local usedExt = safe("getUsedExternalItemStorage", "getUsedExternItemStorage")
  85.     local reportedMax = safe("getMaxItemExternalStorage", "getTotalExternItemStorage")
  86.    
  87.     -- Force-Fix for External Bar
  88.     local displayMaxExt = reportedMax
  89.     if reportedMax <= usedExt or reportedMax == 0 then
  90.         displayMaxExt = EXTERNAL_ITEM_GOAL
  91.     end
  92.  
  93.     -- Header
  94.     canvas.setTextColor(colors.cyan)
  95.     canvas.setCursorPos(math.floor(w/2) - 8, 1)
  96.     canvas.write("AE2 NETWORK DASHBOARD")
  97.    
  98.     -- Bars
  99.     drawBar(3, "POWER ", energy, maxEnergy, colors.green)
  100.     drawBar(5, "DRIVES", usedInt, totalInt, colors.blue)
  101.     drawBar(7, "EXTERN", usedExt, displayMaxExt, colors.orange)
  102.  
  103.     -- Fuel Info
  104.     canvas.setCursorPos(2, 9)
  105.     canvas.setTextColor(colors.yellow)
  106.     canvas.write("== REACTOR FUEL ==")
  107.     canvas.setCursorPos(2, 10)
  108.     canvas.setTextColor(uraniumCount < 1000 and colors.red or colors.white)
  109.     canvas.write("Uranium: " .. uraniumCount)
  110.  
  111.     -- Watchlist Info
  112.     canvas.setCursorPos(2, 12)
  113.     canvas.setTextColor(colors.magenta)
  114.     canvas.write("== WATCHLIST ==")
  115.     local line = 13
  116.     for _, item in ipairs(WATCHLIST) do
  117.         local count = getCount(item.name)
  118.         canvas.setCursorPos(2, line)
  119.         canvas.setTextColor(colors.lightGray)
  120.         canvas.write(item.label .. ": ")
  121.         canvas.setTextColor(colors.white)
  122.         canvas.write(tostring(count))
  123.         line = line + 1
  124.     end
  125.    
  126.     -- Footer stats
  127.     canvas.setCursorPos(2, line + 1)
  128.     canvas.setTextColor(colors.lightGray)
  129.     canvas.write("Phys. Items: " .. usedExt)
  130.    
  131.     canvas.setCursorPos(2, h)
  132.     canvas.setTextColor(colors.white)
  133.     canvas.write("Load: ")
  134.     canvas.setTextColor(colors.green)
  135.     canvas.write(math.floor(safe("getEnergyUsage") or 0) .. " AE/t")
  136.  
  137.     canvas.setVisible(true)
  138.     canvas.setVisible(false)
  139.     sleep(1)
  140. end
  141.  
Advertisement
Add Comment
Please, Sign In to add comment