Advertisement
Guest User

arcfunace

a guest
May 26th, 2016
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.99 KB | None | 0 0
  1.   arc = peripheral.wrap("back")
  2.   m = peripheral.wrap("right")
  3.   m.setTextColor(colors.green)
  4.   m.setBackgroundColor(colors.red)
  5.   term.clear()
  6.   function updateInfo()
  7.     rod1 = arc.getElectrode(1)
  8.     print(tostring(rod1[1]))
  9.     rod2 = arc.getElectrode(2)
  10.     rod3 = arc.getElectrode(3)
  11.     rodMax = 1000
  12.   end
  13.   function calculate()
  14.     print(tostring(rod1))
  15.     perc1 = (rod1/rodMax)*100
  16.     perc2 = (rod2/rodMax)*100
  17.     perc3 = (rod3/rodMax)*100
  18.   end
  19.   function getMonitor()
  20.     x,y = m.getSize()
  21.     Xvalue = x/100
  22.   end
  23.   function display()
  24.     monperc = perc1*Xvalue
  25.     fillspace = math.ceil(monperc)
  26.     m.setBackgroundColor(colors.red)
  27.     m.clear()
  28.     m.setBackgroundColor(colors.green)
  29.     for i = 1,fillspace do
  30.       for j = 1,y do
  31.         m.setCursorPos(i,j)
  32.         m.write(" ")
  33.       end
  34.     end
  35.   end
  36.   while true do
  37.     updateInfo()
  38.     sleep(0.1)
  39.     calculate()
  40.     sleep(0.1)
  41.     getMonitor()
  42.     sleep(0.1)
  43.     display()
  44.     sleep(0.5)
  45.   end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement