Advertisement
Yahve83

test affichage reactors

Jul 31st, 2016
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. reactor = peripheral.wrap("back")
  2. mon = peripheral.wrap("top")
  3. mon.clear()
  4. mon.setBackgroundColor(colors.blue)
  5. color = blue
  6.  
  7. --fuel = 0
  8. --maxFuel = 0
  9.  
  10. function calc(min, max)
  11.  
  12.   percent = 53 / max
  13.  
  14.   x = percent * min
  15.  
  16.   --print("percent: "..percent.." x: "..x)
  17.  
  18.   return 53, x
  19.  
  20. end
  21.  
  22. function progress(current, max, pos1, pos2)
  23.  
  24. --Power
  25.   maxX,x = calc(current,max)
  26.   for i=0,3 do
  27.     for z=1,maxX do
  28.       mon.setCursorPos(pos1+z,pos2+i)
  29.       if z <= x then
  30.         mon.setBackgroundColor(colors.green)
  31.       else
  32.         mon.setBackgroundColor(colors.white)
  33.       end
  34.  
  35.       mon.write(" ")
  36.     end
  37.   end
  38. end
  39.  
  40. function draw(color)
  41.   mon.clear()
  42.  
  43.   mon.setCursorPos(28,1)
  44.   mon.write("Reactor")
  45.  
  46.   mon.setCursorPos(2,10)
  47.   mon.write("Fuel:")
  48.   mon.setCursorPos(1,11)
  49.   mon.write(math.floor((fuel/maxFuel)*100).."%")
  50.  
  51.   mon.setCursorPos(2,16)
  52.   mon.write("RF/t:")
  53.   mon.setCursorPos(1,17)
  54.   mon.write(math.floor(rf/1000).."kRF/t")
  55.  
  56.   progress(power,maxPower,7,3)
  57.   progress(fuel,maxFuel,7,9)
  58.   progress(rf,maxRf,7,15)
  59.  
  60.   if reactor.getActive() == true then
  61.     mon.setBackgroundColor(colors.blue)
  62.   else
  63.     mon.setBackgroundColor(colors.red)
  64.   end
  65. end
  66.   sleep(2)
  67. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement