Advertisement
tbrixey

Monitor Battery and Output to monitor Minecraft

Oct 12th, 2022
1,491
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.69 KB | Gaming | 0 0
  1. monitor = peripheral.wrap("top")
  2.  
  3. monitor.setCursorPos(1, 1)
  4. monitor.clear()
  5. monX, monY = monitor.getSize()
  6. monitor.setTextScale(0.5)
  7. monitor.setTextColor(43)
  8. monitor.setCursorBlink(true)
  9. monitor.write("Starting...")
  10. monitor.setCursorPos(1, 2)
  11. rednet.open("right")
  12.  
  13. function write(msg)
  14.   curX, curY = monitor.getCursorPos()
  15.   monitor.write(msg)
  16.   if curY == monY then
  17.       monitor.scroll(1)
  18.       monitor.setCursorPos(1, monY)
  19.   else
  20.       monitor.setCursorPos(1, curY + 1)
  21.   end
  22. end
  23.  
  24. function displayBattery()
  25.   while true do
  26.     senderId, message, protocol = rednet.receive("battery")
  27.     if protocol == "battery" then
  28.       write(message)
  29.     end
  30.   end
  31. end
  32.  
  33. displayBattery()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement