dynamicXblue

Minecraft Sound Player CC

Jul 12th, 2022 (edited)
721
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.07 KB | None | 0 0
  1. local monitor = peripheral.find("monitor")
  2. local source = peripheral.wrap("back")
  3. local modem = peripheral.find("modem")
  4.  
  5. local powerPerc = 0
  6. local width, height = monitor.getSize()
  7. local wCenter, hCenter = math.floor(width/2)+1, math.floor(height/2)+1
  8. local scale = width/15
  9.  
  10. function monitorSetup(monitor)
  11.     monitor.setTextScale(0.5)
  12.  
  13.     paintutils.drawFilledBox(1, 1, width, height, colors.black)
  14.  
  15.     if width % 2 ~= 0 then
  16.         --Main Sqr
  17.         paintutils.drawBox(wCenter-(4*scale), hCenter+(3*scale), wCenter+(4*scale), hCenter-(3*scale), colors.white)
  18.         --Bat Top
  19.         paintutils.drawBox(wCenter-(2*scale), hCenter-(3*scale), wCenter+(2*scale), hCenter-(4*scale), colors.white)
  20.     else
  21.         --Main Sqr
  22.         paintutils.drawBox(wCenter-(4*scale), hCenter+(3*scale), wCenter+(4*scale), hCenter-(3*scale), colors.white)
  23.         --Bat Top
  24.         paintutils.drawBox(wCenter-(2*scale), hCenter-(3*scale), wCenter+(2*scale+1), hCenter-(4*scale + 1), colors.white)
  25.     end
  26. end
  27.  
  28. function update(h)
  29.  
  30.     if monitor ~= nil then
  31.         local y = hCenter+(3*scale-1)
  32.         local nbars = (4*scale-1) + (4*scale-1) - scale
  33.  
  34.         local color
  35.         paintutils.drawFilledBox(wCenter-(4*scale-1), hCenter+(3*scale-1), wCenter+(4*scale-1), hCenter-(3*scale-1), colors.black)
  36.  
  37.         if h > 66 then
  38.             color = colors.green
  39.         elseif h > 33 then
  40.             color = colors.orange
  41.         else
  42.             color = colors.red
  43.         end
  44.  
  45.         if h ~= 0 then
  46.             if width % 2 ~= 0 then
  47.                 paintutils.drawFilledBox(wCenter-(4*scale-1), y, wCenter+(4*scale-1), y-math.floor(nbars*h/100)+1, color)
  48.             else
  49.                 paintutils.drawFilledBox(wCenter-(4*scale-1), y, wCenter+(4*scale-1), y-math.floor(nbars*h/100)+1, color)
  50.             end
  51.         end
  52.     end
  53.  
  54.     modem.transmit(6, h)
  55.    
  56. end
  57.  
  58. if monitor ~= nil then
  59.     term.redirect(monitor)
  60.     monitorSetup(monitor)
  61. end
  62.  
  63. while true do
  64.     powerPerc = (source.getEnergy() / source.getMaxEnergy()) * 100
  65.     update(powerPerc)
  66.     os.sleep(1)
  67. end
Advertisement
Add Comment
Please, Sign In to add comment