TheTrashinger

Reaktor Port

Dec 6th, 2019
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.63 KB | None | 0 0
  1. computerName = "reaktor1"
  2. controlUnit = "pcc1"
  3. CUid = 0
  4.  
  5. rednet.open("top")
  6. rednet.host(computerName,computerName)
  7. reactor = peripheral.find("BigReactors-Reactor")
  8.  
  9.  
  10. reactorActive = false
  11. reactorRF = 0
  12. reactorCRL = 0
  13. reactorTemp = 0
  14.  
  15.    
  16.  
  17. function lookup()
  18.     while true do
  19.         CUid = rednet.lookup(controlUnit)
  20.         sleep(5)
  21.     end
  22. end
  23.  
  24.  
  25. function send()
  26.  
  27.     while true do
  28.         local LreactorActive = reactor.getActive()
  29.         local LreactorRF = reactor.getEnergyProducedLastTick(0)
  30.         local LreactorCRL =  reactor.getControlRodLevel(0)
  31.         local LreactorTemp =  reactor.getFuelTemperature (0)
  32.        
  33.         reactorActive = LreactorActive
  34.         reactorRF = LreactorRF
  35.         reactorCRL = LreactorCRL
  36.         reactorTemp = LreactorTemp
  37.        
  38.         rednet.broadcast(LreactorActive,computerName.."AK")
  39.         rednet.broadcast(LreactorRF,computerName.."RF")
  40.         rednet.broadcast(LreactorCRL,computerName.."CRL")
  41.         rednet.broadcast(LreactorTemp,computerName.."Temp")
  42.         sleep(2)
  43.     end
  44.  
  45. end
  46.  
  47. function recieve()
  48.    
  49.     while true do
  50.         event, sId, message, prot = os.pullEvent("rednet_message")
  51.        
  52.         if CUid and (CUid == sId) then
  53.        
  54.             if prot==computerName.."ToggleAK" then
  55.                 if message==computerName.."ON" then
  56.                     reactor.setActive(true)
  57.                     print("Fernsteuerung: Reaktor Aktiviert")
  58.                 elseif message==computerName.."OFF" then
  59.                     reactor.setActive(false)
  60.                     print("Fernsteuerung: Reaktor Deaktiviert")
  61.                 end
  62.             end
  63.            
  64.            
  65.             if prot==computerName.."changeCRL" then
  66.                 reactor.setAllControlRodLevels(message)
  67.                 print("Fernsteuerung: Reaktor CRL wurde auf "..message.." gestellt")
  68.             end
  69.            
  70.         end
  71.     end
  72. end
  73.  
  74. parallel.waitForAny(lookup, send, recieve)
Add Comment
Please, Sign In to add comment