Tomodachi94

infuserstatus

Jun 19th, 2026 (edited)
46
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.70 KB | Source Code | 0 0
  1. -- SPDX-FileCopyrightText: 2026 Tomodachi94
  2. -- SPDX-License-Identifier: MIT
  3. -- Display the status of a Thermal Expansion Energetic Infuser on a monitor.
  4.  
  5. print("infuserstatus by Tomodachi94")
  6. print("Setup:")
  7. print("Place this computer behind an Energetic Infuser. Place two monitors above the computer, horizontally next to each other.")
  8.  
  9. local infuser = peripheral.wrap("top")
  10. -- The monitor should be two advanced monitors next to each other
  11. local monitor = peripheral.wrap("right")
  12.  
  13. local function round(num)
  14.     local decimalPlaces = 0
  15.     local mult = 10^(decimalPlaces)
  16.     return math.floor(num * mult + 0.5) / mult
  17. end
  18.  
  19. local function chargingItemStatus()
  20.     local item = infuser.getStackInSlot("1")
  21.     monitor.setCursorPos(1, 1)
  22.     monitor.write("Charging " .. item["name"])
  23.     local energyPerTick = tostring(infuser.getEnergyPerTick()) .. " RF/t"
  24.     local energyInItem = tostring(item["energyStored"])
  25.     local itemEnergyCapacity = tostring(item["maxEnergyStored"])
  26.     monitor.setCursorPos(1, 2)
  27.     local chargingMessage = string.format("%s / %s (%s)", energyInItem, itemEnergyCapacity, energyPerTick)
  28.     monitor.write(chargingMessage)
  29.     monitor.setCursorPos(1, 3)
  30.     local percentage = round(( item["energyStored"] / item["maxEnergyStored"] ) * 100)
  31.     monitor.write(tostring(percentage) .. "% charged")
  32. end
  33.  
  34. while true do
  35.     sleep(0)
  36.     monitor.setTextScale(0.5)
  37.     monitor.setCursorPos(1, 1)
  38.     monitor.write("Waiting...                          ") -- also clears the line
  39.     monitor.setCursorPos(1, 2)
  40.     monitor.clearLine()
  41.     monitor.setCursorPos(1, 3)
  42.     monitor.clearLine()
  43.     while type(infuser.getStackInSlot("1")) == "table" do
  44.         local status = pcall(chargingItemStatus)
  45.         if status == false then return end
  46.     end
  47. end
  48.  
Advertisement
Add Comment
Please, Sign In to add comment