Advertisement
TitanChase

Untitled

Oct 25th, 2014
216
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.85 KB | None | 0 0
  1. local tArgs = { ... }
  2. local reactor
  3. local reactorSettings = {}
  4. local monitors = {}
  5. local modem
  6.  
  7. function get(setting)
  8. return reactorSettings[setting]
  9. end
  10.  
  11. function updateReactorSettings()
  12. if (reactor ~= nil) then
  13. reactorSettings = {}
  14. reactorSettings["isConnected"] = reactor.getConnected()
  15. reactorSettings["isActive"] = reactor.getActive()
  16. reactorSettings["energyStored"] = reactor.getEnergyStored()
  17. reactorSettings["fuelTemp"] = reactor.getFuelTemperature()
  18. reactorSettings["casingTemp"] = reactor.getCasingTemperature()
  19. reactorSettings["fuelAmount"] = reactor.getFuelAmount()
  20. reactorSettings["wasteAmount"] = reactor.getWasteAmount()
  21. reactorSettings["fuelAmountMax"] = reactor.getFuelAmountMax()
  22. reactorSettings["rfPerTick"] = reactor.getEnergyProducedLastTick()
  23. reactorSettings["hotFluidProduced"] = reactor.getHotFluidProducedLastTick()
  24. reactorSettings["coolantType"] = reactor.getCoolantType()
  25. reactorSettings["coolantAmount"] = reactor.getCoolantAmount()
  26. reactorSettings["coolantAmountMax"] = reactor.getCoolantAmountMax()
  27. reactorSettings["hotFluidType"] = reactor.getHotFluidType
  28. reactorSettings["fuelReactivity"] = reactor.getFuelReactivity()
  29. reactorSettings["fuelConsumedPerTick"] = reactor.getFuelConsumedLastTick()
  30. reactorSettings["isActivelyCooled"] = reactor.isActivelyCooled()
  31. else
  32. print("Reactor not Set! use bindReactor(side)")
  33. shell.exit()
  34. end
  35. end
  36.  
  37.  
  38. function bindReactor(side)
  39. reactor = peripheral.wrap(side)
  40. if(reactor.getConnected()) then
  41. updateReactorSettings()
  42. else
  43. print("Reactor not found at the " .. side .. " side")
  44. sleep(5)
  45. shell.exit()
  46. end
  47. end
  48.  
  49. function bindReactorOnNetwork(name, modemSide)
  50. modem = peripheral.wrap(modemSide)
  51. bindReactor(name)
  52. end
  53.  
  54. function monitorReactor()
  55. while true do
  56. updateReactorSettings()
  57. term.clear()
  58. term.setCursorPos(1, 1)
  59. drawReactorInfo()
  60. sleep(1)
  61. end
  62. end
  63.  
  64. function drawValues()
  65. end
  66.  
  67. function drawReactorInfo()
  68. print("Reactor:")
  69. print("Active: " .. tostring(reactorSettings["isActive"]))
  70. if(getReactorType() == "RF") then
  71. print("RF per tick: " .. tostring(reactorSettings["rfPerTick"]))
  72. else
  73. print("Hot Fluid per tick: " .. tostring(reactorSettings["hotFluidProduced"]))
  74. end
  75. print("Energy Stored: " .. tostring(reactorSettings["energyStored"]))
  76. print("Casing Temp: " .. tostring(reactorSettings["casingTemp"]))
  77. print("Fuel Temp: " .. tostring(reactorSettings["fuelTemp"]))
  78. print("Reactivity: " .. tostring(reactorSettings["fuelReactivity"]))
  79. print("Fuel per tick: " .. tostring(reactorSettings["fuelConsumedPerTick"]))
  80. end
  81.  
  82. function getReactorType()
  83. if(reactor == nil) then
  84. return nil
  85. end
  86. if(reactorSettings["isActivelyCooled"]) then
  87. return "HF"
  88. else
  89. return "RF"
  90. end
  91. end
  92.  
  93.  
  94. function bindModem(side)
  95. type = peripheral.getType(side)
  96. if(type == "modem") then
  97. modem = side
  98. else
  99. print("No Modem Found at the " .. side .. " side!")
  100. shell.exit()
  101. end
  102. end
  103.  
  104. function receiveUpdate()
  105. rednet.open(modem)
  106. senderid, message = rednet.receive()
  107. print("Recieved Message: {" .. message[1] .. ", " .. tostring(message[2]) .. "}")
  108. rednet.close(modem)
  109. decodeMessage(message)
  110. end
  111.  
  112. function decodeMessage(message)
  113. print("Decoding message {" .. messages[1] .. ", " .. tostring(messages[2]) .. "}")
  114. reactorSettings[message[1]] = message[2]
  115. end
  116.  
  117. function sendUpdates()
  118. rednet.open(modem)
  119. for key, value in pairs(reactorSettings) do
  120. rednet.broadcast({key, value})
  121. end
  122. rednet.close(modem)
  123. end
  124.  
  125. if(tArgs[1] == "monitor") then
  126. if(tArgs[2] == nil) then
  127. print("Usage: monitor <Reactor Side>")
  128. else
  129. bindReactor(tArgs[2])
  130. monitorReactor()
  131. end
  132. end
  133.  
  134. if(tArgs[1] == "values") then
  135. if(tArgs[2] == nil) then
  136. print("Usage: values <Reactor Side>")
  137. else
  138. bindReactor(tArgs[2])
  139. for key, value in pairs(reactorSettings) do
  140. print(key)
  141. end
  142. end
  143. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement