Advertisement
Guest User

startup

a guest
May 6th, 2016
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.32 KB | None | 0 0
  1. while true do
  2.  sleep(300)
  3.  
  4. local mon = peripheral.wrap("monitor_61")
  5. local pylon = peripheral.wrap("draconic_rf_storage_5")
  6. monX, monY = mon.getSize()
  7.  
  8. function clear()
  9.   mon.setBackgroundColor(colors.black)
  10.   mon.clear()
  11.   mon.setCursorPos(1,6)
  12. end
  13.  
  14. function drawText(x, y, text, color_txt, color_bg)
  15.   mon.setBackgroundColor(color_bg)
  16.   mon.setTextColor(color_txt)
  17.   mon.setCursorPos(x,y)
  18.   mon.write(text)
  19. end
  20.  
  21. function drawLine(x, y, length, size, color_bar)
  22.   for yPos = y, y+size-1 do
  23.     mon.setBackgroundColor(color_bar)
  24.     mon.setCursorPos(x, yPos)
  25.     mon.write(string.rep(" ", length))
  26.   end
  27. end
  28.  
  29. function drawProg(x, y, name, length, size, minVal, maxVal, color_bar, color_bg)
  30.   drawLine(x, y, length, size, color_bg)
  31.   local barSize = math.floor((minVal/maxVal)*length)
  32.   drawLine(x, y, barSize, size, color_bar)
  33.   local text = name.." "..math.floor((minVal/maxVal)*100).."%"
  34.   if barSize > length/2+#text/2 then
  35.     drawText(x+length/2-#text/2, y+size/2, text, colors.black, color_bar)
  36.   elseif barSize > #text then
  37.     drawText((x+barSize)-#text, y+size/2, text, colors.black, color_bar)
  38.   else
  39.     drawText(x+length/2-#text/2, y+size/2, text, colors.black, color_bg)
  40.   end
  41. end
  42.  
  43.   drawProg(2,8, " ", 27, 3, pylon.getEnergyStored(), pylon.getMaxEnergyStored(), colors.lime, colors.gray)
  44.  
  45. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement