Advertisement
Helladarion

cc_rcontrol

Apr 21st, 2015
219
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.11 KB | None | 0 0
  1. p=peripheral.wrap("back")
  2. e=peripheral.wrap("tile_thermalexpansion_cell_reinforced_name_0")
  3. m=peripheral.wrap("monitor_1")
  4.  
  5. function informacao(tipo)
  6.    
  7.         m.clear()
  8.         m.setCursorPos(1,1)
  9.         m.write("Energia Armazenada Atual: "..percent.." de 20000000 RF")
  10.         m.setCursorPos(1,2)
  11.         m.write("Reator: ".. status)
  12.         m.setCursorPos(1,3)
  13.         m.write("Energia Produzida: ".. p.getEnergyProducedLastTick())
  14.     if tipo == "liga" then
  15.         m.setCursorPos(1,4)
  16.         m.write("Ligando Reator Energia Muito Baixa")
  17.     elseif tipo == "desliga" then
  18.         m.setCursorPos(1,4)
  19.         m.write("Desligando Reator... Tudo Certo Agora")
  20.     end
  21. end
  22.  
  23.  
  24. function controla()
  25.     while true do
  26.          sleep(1)
  27.          energia=e.getEnergyStored()/20000000*100
  28.          percent=(string.sub(energia, 1, 4) .. "%")
  29.          if p.getEnergyStored() <= 20000 then
  30.             p.setActive(true)
  31.             informacao("liga")
  32.          elseif e.getEnergyStored() >= 19900000 then
  33.             p.setActive(false)
  34.             informacao("desliga")
  35.          else
  36.             informacao("nada")
  37.          end
  38.          if p.getEnergyProducedLastTick() > 0 then
  39.             status="Ligado"
  40.          else
  41.             status="Desligado"
  42.          end
  43.            
  44.     end
  45. end
  46.      
  47. controla()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement