Guest User

startup

a guest
Apr 11th, 2015
311
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.64 KB | None | 0 0
  1. local turbines = {peripheral.find("BigReactors-Turbine")}
  2. local numTurbine = #turbines
  3. local top = 1846
  4. local bot = 1838
  5. local goal = 1842
  6.  
  7. local fix = {".", ".", ".", "."}
  8.  
  9. rednet.open("front")
  10.  
  11. print(numTurbine)
  12.  
  13. function stuff(tur, eng, act)
  14.   tur.setInductorEngaged(eng)
  15.   tur.setActive(act)
  16. end
  17.  
  18. while true do
  19.  
  20.   print("1")
  21.  
  22.   for i=1, numTurbine do
  23.  
  24.     local t = turbines[i]
  25.  
  26.     local speed = t.getRotorSpeed()
  27.     local power = t.getEnergyProducedLastTick()
  28.     local engaged = t.getInductorEngaged()
  29.     local active = t.getActive()
  30.    
  31.     print("2")
  32.    
  33.     if(speed > top) then
  34.       print("3a1")
  35.       stuff(t,true,false)
  36.       fix[i] = "H"
  37.       print("3a2")
  38.     elseif(speed < bot) then
  39.       print("3b1")
  40.       stuff(t,false,true)
  41.       fix[i] = "L"
  42.       print("3b2")
  43.     end
  44.    
  45.     if(fix[i] == "H") and (speed < goal) then
  46.       print("4a1")
  47.       stuff(t,true,true)
  48.       fix[i] = "."
  49.       print("4a2")
  50.     elseif(fix[i] == "L") and (speed > goal) then
  51.       print("4b1")
  52.       stuff(t,true,true)
  53.       fix[i] = "."
  54.       print("4b2")
  55.     elseif(fix[i] == ".") then
  56.       print("4c1")
  57.       fix[i] = "_"
  58.       print("4c2")
  59.     elseif(fix[i] == "_") then
  60.       print("4d1")
  61.       fix[i] = "."
  62.       print("4d2")
  63.     end
  64.    
  65.     print("here1")
  66.    
  67.     rednet.send(62,
  68.       {string.format("p:%d",power),
  69.        string.format("r:%d",speed),
  70.        "c:"..string.sub(tostring(engaged),1,1)..
  71.        "a:"..string.sub(tostring(active),1,1)..
  72.        "s:"..fix[i]}, i)
  73.        
  74.     print("here2")
  75.        
  76.     print("5")
  77.      
  78.     sleep(0.025)
  79.    
  80.     print("6")
  81.   end
  82.  
  83. end
Advertisement
Add Comment
Please, Sign In to add comment