SHARE
TWEET

reactorServer

a guest Jan 6th, 2016 53 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. side = "right"
  2. id = 10
  3. rednet.open(side)
  4. r = peripheral.wrap("back")
  5.  
  6. --Reactor Info Variables--
  7. isActive = r.getActive()
  8. fuel = r.getFuelAmount()
  9. maxFuel = r.getFuelAmountMax()
  10. energyStored = r.getEnergyStored()
  11. RFT = math.floor(r.getEnergyProducedLastTick())
  12. RFS = (RFT * 20)
  13. reactivity = r.getFuelReactivity()
  14. waste = r.getWasteAmount()
  15. caseTemp = math.floor(r.getCasingTemperature())
  16. fuelTemp = math.floor(r.getFuelTemperature())
  17. reactorInfo = {isActive, fuel, maxFuel, energyStored, RFS, reactivity, waste, caseTemp, fuelTemp}
  18.  
  19. --Reactor Control
  20. function powerSwitch()
  21.  if r.getActive() == true then
  22.   rednet.send(id, "Powering Off")
  23.   r.setActive(false)
  24.  elseif r.getActive() == false then
  25.   rednet.send(id, "Powering On")
  26.   r.setActive(true)
  27.  end
  28. end
  29.  
  30. --Main Program
  31.  
  32. message = { os.pullEvent("rednet_message") }
  33. for i = 1, #message do
  34.  print(message[i])
  35. end
  36.  
  37.  
  38.  
  39. if message[2] == id and message[3] == "reactorInfo" then
  40.  rednet.send(id, reactorInfo)
  41. elseif message[2] == id and message[3] == "power" then
  42.  powerSwitch()
  43. elseif message[2] == id and message[3] == "waste" then
  44.  r.doEjectWaste()
  45.  rednet.send(id, "Waste Ejected")
  46. 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