Shadows_Player

Matrix

Jan 7th, 2022
856
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.22 KB | None | 0 0
  1. local wmod = peripheral.wrap("top")
  2. local event, modemSide, senderChannel, replyChannel, message, senderDistance = os.pullEvent("modem_message")
  3. wmod.closeAll()
  4. wmod.open(1)
  5.  
  6.  
  7. local function centerText(text)
  8.   x,y = term.getSize()
  9.   x1,y1 = term.getCursorPos()
  10.   term.setCursorPos((math.floor(x/2) - (math.floor(#text/2))), y1)
  11.   print(text)
  12. end
  13.  
  14.  
  15.  
  16.  
  17. function drawbar()
  18.    bar = math.floor(((message["cur"]/message["maxe"]))*(x-2)+0.4)
  19.    --Draw BackGround Bar
  20.    term.setCursorPos(2,y-4)
  21.    term.setBackgroundColor(colors.white)
  22.    print(string.rep(" ",x-2))
  23.    -- Draw Percent Bar
  24.    term.setCursorPos(2,y-4)
  25.    term.setBackgroundColor(colors.red)
  26.    print(string.rep(" ",bar))  
  27. end
  28.  
  29.  
  30.  
  31. while redstone.testBundledInput("front", colors.blue) == true do
  32.   term.setCursorPos(1,1)
  33.   term.setBackgroundColor(colors.black)
  34.   term.setTextColor(colors.white)
  35.   term.clear()
  36.   centerText("Matrix Energy :")
  37.   term.setCursorPos(1,3)
  38.   print("Percentage: "..message["per"])
  39.   term.setCursorPos(1,4)
  40.   print("Current Energy: "..message["scur"])
  41.   drawbar()
  42.   sleep(1)
  43. end
  44.  if redstone.testBundledInput("front", colors.blue) == false then
  45.  term.setBackgroundColor(colors.black)
  46.  term.clear()
  47.  os.reboot()
  48.  end
Advertisement
Add Comment
Please, Sign In to add comment