subzero22

Draconic Reactor Status

Sep 20th, 2016
132
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. dreactor = peripheral.wrap("draconic_reactor_3")
  2. dmon = peripheral.wrap("monitor_23")
  3.  
  4. function clear()
  5. dmon.clear()
  6. term.clear()
  7. term.setCursorPos(1,1)
  8. dmon.setCursorPos(1,1)
  9. end
  10.  
  11.  
  12. while true do
  13.  if peripheral.isPresent("draconic_reactor_3") then
  14.  if peripheral.isPresent("monitor_23") then
  15.   clear()
  16.   term.setCursorPos(16,1)
  17.   dmon.setCursorPos(7,1)
  18.   print("Draconic Reactor")
  19.   dmon.write("Draconic Reactor")
  20.  
  21.   tbl = peripheral.call("draconic_reactor_3", "getReactorInfo")
  22.   tbl = dreactor.getReactorInfo()
  23.  
  24.  for k, v in pairs (tbl) do
  25.   if k == "status" then
  26.     stats = v
  27.     term.setCursorPos(8,3)
  28.     dmon.setCursorPos(8,3)
  29.     print("Status: "..stats)
  30.     dmon.write("Status: "..stats)
  31.   end
  32.   if k == "fuelConversion" then
  33.     term.setCursorPos(2,9)
  34.     dmon.setCursorPos(2,9)
  35.     conv = v / 9088 * 100
  36.     print("F. Converted: "..conv.."%")
  37.     dmon.write("F. Converted: "..conv.."%")
  38.    if conv >= 80 then
  39.      dreactor.stopReactor()
  40.      term.setCursorPos(1,10)
  41.      dmon.setCursorPos(1,10)
  42.      print("Ran Out Of Fuel")
  43.      dmon.write("Ran Out Of Fuel")
  44.    end
  45.   end
  46.   if k == "temperature" then
  47.    if v >= 8500 then
  48.      dreactor.stopReactor()
  49.      clear()
  50.      term.setCursorPos(1,10)
  51.      dmon.setCursorPos(1,10)
  52.      dmon.write("Reactor Overheated")
  53.      print("Reactor Overheated")
  54.    end
  55.     term.setCursorPos(3,4)
  56.     dmon.setCursorPos(3,4)
  57.     print("Temperature: "..v)
  58.     dmon.write("Temperature: "..v)
  59.   end
  60.   if stats == "charged" then
  61.     dreactor.activateReactor()
  62.   end
  63.   if k == "fieldDrainRate" then
  64.     term.setCursorPos(3,6)
  65.     dmon.setCursorPos(3,6)
  66.     print("Field Drain: "..v)
  67.     dmon.write("Field Drain: "..v)
  68.   end
  69.   if k == "generationRate" then
  70.     term.setCursorPos(4,5)
  71.     dmon.setCursorPos(4,5)
  72.     print("Generating: "..v)
  73.     dmon.write("Generating: "..v)
  74.   end
  75.   if k == "energySaturation" then
  76.     term.setCursorPos(1,7)
  77.     dmon.setCursorPos(1,7)
  78.     spos = v / 876543209 * 100
  79.     print("RF Saturation: "..spos.."%")
  80.     dmon.write("RF Saturation: "..spos.."%")
  81.    if spos <= 20 then
  82.     if stats == "offline" or "charging" then
  83.     else
  84.       dreactor.stopReactor()
  85.       clear()
  86.       term.setCursorPos(1,10)
  87.       dmon.setCursorPos(1,10)
  88.       dmon.write("Shutdown.. Drained Too Fast")
  89.       print("Shutdown.. Drained Too Fast")
  90.     end
  91.    end
  92.   end
  93.   if k == "fieldStrength" then
  94.     term.setCursorPos(7,8)
  95.     dmon.setCursorPos(7,8)
  96.     fpos = v / 87654320 * 100
  97.     print("Shields: "..fpos.."%")
  98.     dmon.write("Shields: "..fpos.."%")
  99.    if fpos <= 25 then
  100.     if stats == "offline" or "charging" then
  101.     else
  102.       dreactor.stopReactor()
  103.       clear()
  104.       term.setCursorPos(1,10)
  105.       dmon.setCursorPos(1,10)
  106.       dmon.write("Shutdown.. Shields failing")
  107.       print("Shutdown.. Shields failing")
  108.     end
  109.    end
  110.   end
  111.  end
  112.   sleep(1)
  113. else
  114. clear()
  115. print("Can't find monitor")
  116. sleep(10)
  117. --os.reboot()
  118. end
  119. else
  120. clear()
  121. dmon.write("Couldn't Find Reactor")
  122. print("Couldn't find reactor")
  123. sleep(10)
  124. --os.reboot()
  125. end
  126. end
Add Comment
Please, Sign In to add comment