SHARE
TWEET

rcComputer.Lua

ALpha_R Dec 6th, 2019 (edited) 90 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  
  2.  
  3. --changeState à finir
  4.  
  5.  
  6.  
  7.  
  8.  
  9. -------------------------------------------------//Initialisation
  10.  
  11. local ptc = "reactorNetwork"
  12. local hostname = "rcComputer"
  13.  
  14. rednet.open("front")
  15. rednet.host(ptc, hostname)
  16.  
  17. local rcServer
  18.  
  19. local reactor, turbine1, turbine2, turbine3
  20.  
  21. reactor = peripheral.wrap("BigReactors-Reactor_")
  22. turbine1 = peripheral.wrap("BigReactors-Turbine_")
  23. turbine2 = peripheral.wrap("BigReactors-Turbine_")
  24. turbine3 = peripheral.wrap("BigReactors-Turbine_")
  25.  
  26. local info = {}
  27. info.tb = {}
  28. info.rc = {}
  29. info.bt = {}
  30.  
  31. local change = {}
  32.  
  33. local res
  34.  
  35. -------------------------------------------------//Connection au server
  36.  
  37. print("Waiting connection from the reactorNetwork server")
  38.  
  39. rcServer = rednet.lookup(ptc, "rcServer")
  40.  
  41. print("Logged")
  42.  
  43. -------------------------------------------------//input()
  44.  
  45. function input()
  46.     info.bt.rcActive = reactor.getActive()
  47.     info.rc.rcActive = reactor.getActive()
  48.     info.rc.fuelTemp = reactor.getFuelTemperature()
  49.     info.rc.caseTemp = reactor.getCasingTemperature()
  50.     info.rc.fuelAmount= reactor.getFuelAmount()
  51.     info.rc.wasteAmount = reactor.getWasteAmount()
  52.  
  53.     --reactor
  54.  
  55.     info.bt.tb1Active = turbine1.getActive()
  56.     info.bt.tb1Engaged = turbine1.getInductorEngaged()
  57.     info.tb.tb1Active = turbine1.getActive()
  58.     info.tb.tb1energyStored = turbine1.getEnergyStored()
  59.     info.tb.tb1energyLastTick = turbine1.getEnergyProducedLastTick()
  60.     info.tb.tb1rotorSpeed = turbine1.getRotorSpeed()
  61.  
  62.     --turbine1
  63.  
  64.     info.bt.tb2Active = turbine2.getActive()
  65.     info.bt.tb2Engaged = turbine2.getInductorEngaged()
  66.     info.tb.tb2Active = turbine2.getActive()
  67.     info.tb.tb2energyStored = turbine2.getEnergyStored()
  68.     info.tb.tb2energyLastTick = turbine2.getEnergyProducedLastTick()
  69.     info.tb.tb2rotorSpeed = turbine2.getRotorSpeed()
  70.  
  71.     --turbine2
  72.  
  73.     info.bt.tb3Active = turbine3.getActive()
  74.     info.bt.tb3Engaged = turbine3.getInductorEngaged()
  75.     info.tb.tb3Active = turbine3.getActive()
  76.     info.tb.tb3energyStored = turbine3.getEnergyStored()
  77.     info.tb.tb3energyLastTick = turbine3.getEnergyProducedLastTick()
  78.     info.tb.tb3rotorSpeed = turbine3.getRotorSpeed()
  79.  
  80.     --turbine3
  81. end
  82.  
  83. -------------------------------------------------//sendInfo()
  84.  
  85. function sendInfo()
  86.     rednet.send(rcServer, info, ptc)
  87. end
  88.  
  89. -------------------------------------------------//getInfo()
  90.  
  91. function getInfo()
  92.     res, change = rednet.receive(ptc, 10)
  93. end
  94.  
  95. -------------------------------------------------//changeState()
  96.  
  97. function changeState()
  98.     reactor.setActive(change.rcActive)
  99.     turbine1.setActive(change.tb1Active)
  100.     turbine2.setActive(change.tb2Active)
  101.     turbine3.setActive(change.tb3Active)   
  102.     turbine1.setInductorEngaged(change.tb1Engaged)
  103.     turbine2.setInductorEngaged(change.tb2Engaged)
  104.     turbine3.setInductorEngaged(change.tb3Engaged)
  105. end
  106.  
  107. -------------------------------------------------//Main script
  108.  
  109. while(true)do
  110.     os.sleep(0)
  111.     input()
  112.     sendInfo()
  113.     getInfo()
  114.     changeState()
  115. end
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top