Advertisement
Ubidibity

enegizer.lua

May 23rd, 2025 (edited)
193
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.49 KB | Gaming | 0 0
  1. -- Grok's third attempt to get my enegizer cube working in Minecraft ATM10
  2. -- second revision too much information for the turtle console, I'm adding a 3x4 (WxH) monitor on top of an advanced computer and outputting there
  3. -- third revision correcting up with top and some other additional activation attempts, also fixed the term.restore error (or at
  4. -- least trapped it)
  5.  
  6. -- Connect to the Energizer peripheral (on the "back" side)
  7. local energizer = peripheral.wrap("back")
  8.  
  9. -- Connect to the Advanced Monitor peripheral (on the "top" side)
  10. local monitor = peripheral.wrap("top")
  11.  
  12. -- Check if peripherals are connected
  13. if not energizer then
  14.     error("Energizer not found on back side!")
  15. end
  16.  
  17. if not monitor then
  18.     error("Monitor not found on top side!")
  19. end
  20.  
  21. -- Store the current terminal device (the Advanced Computer's screen)
  22. local console = term.current()
  23.  
  24. -- Set the monitor as the output terminal
  25. term.redirect(monitor)
  26.  
  27. -- Clear the monitor and set text properties
  28. monitor.clear()
  29. monitor.setTextScale(0.5) -- Default scale for readability (1 pixel = 1 character)
  30. monitor.setCursorPos(1, 1)
  31. monitor.setTextColor(colors.white)
  32. monitor.setBackgroundColor(colors.black)
  33.  
  34. -- Print the Energizer status to the monitor
  35. monitor.write("Energizer Status")
  36. monitor.setCursorPos(1, 2)
  37. monitor.write("--------------")
  38.  
  39. monitor.setCursorPos(1, 3)
  40. monitor.write("Assembled: " .. tostring(energizer.mbIsAssembled()))
  41.  
  42. monitor.setCursorPos(1, 4)
  43. monitor.write("Active: " .. tostring(energizer.getActive()))
  44.  
  45. monitor.setCursorPos(1, 5)
  46. monitor.write("Paused: " .. tostring(energizer.mbIsPaused()))
  47.  
  48. monitor.setCursorPos(1, 6)
  49. monitor.write("Energy: " .. energizer.getEnergyStoredAsText())
  50.  
  51. monitor.setCursorPos(1, 7)
  52. monitor.write("Capacity: " .. energizer.getEnergyCapacityAsText())
  53.  
  54. monitor.setCursorPos(1, 8)
  55. monitor.write("In Last: " .. energizer.getEnergyInsertedLastTickAsText())
  56.  
  57. monitor.setCursorPos(1, 9)
  58. monitor.write("Out Last: " .. energizer.getEnergyExtractedLastTickAsText())
  59.  
  60. monitor.setCursorPos(1, 10)
  61. monitor.write("Connected: " .. tostring(energizer.mbIsConnected()))
  62.  
  63. monitor.setCursorPos(1, 11)
  64. local minCoord = energizer.mbGetMinimumCoordinate()
  65. monitor.write("Min: " .. minCoord[1] .. "," .. minCoord[2] .. "," .. minCoord[3])
  66.  
  67. monitor.setCursorPos(1, 12)
  68. local maxCoord = energizer.mbGetMaximumCoordinate()
  69. monitor.write("Max: " .. maxCoord[1] .. "," .. maxCoord[2] .. "," .. maxCoord[3])
  70.  
  71. -- Restore the terminal to the computer screen
  72. term.redirect(console)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement