Advertisement
Guest User

Untitled

a guest
Jan 22nd, 2018
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.47 KB | None | 0 0
  1. --print("Nuclear Controller Active")
  2.  
  3. local reactorLoc = "-1,-1,-1"
  4. local threshold = 65
  5. local sensorSide = "top"
  6. local reactorSide = "back"
  7.  
  8. function listener()
  9. --print("poop")
  10. while true do
  11. local event = os.pullEventRaw()
  12. --print("debug")
  13. if event == "terminate" then
  14. term.clear()
  15. term.setCursorPos(1,1)
  16. print("Termination call detected")
  17. print("Powering off reactor")
  18. redstone.setOutput(reactorSide,false)
  19. print("Reactor powered off")
  20. return
  21. --else
  22. --print("received")
  23. end
  24. end
  25. end
  26.  
  27. os.loadAPI("ocs/apis/sensor")
  28. mySens = sensor.wrap(sensorSide)
  29. local reactorActive = false
  30. redstone.setOutput(reactorSide,false)
  31. --c1 = coroutine.create(listener)
  32. --coroutine.resume(c1)
  33. function MainFunct()
  34. while true do
  35. term.clear()
  36. term.setCursorPos(1,1)
  37. print("Nuclear Controller Active")
  38. local deets = mySens.getTargetDetails(reactorLoc)
  39. local curTemp = deets["HeatPercentage"]
  40. if deets["Active"] then
  41. print("Reactor Active")
  42. else
  43. print("Reactor Inactive")
  44. end
  45. print("Reactor Heat at "..curTemp.."%")
  46. if (not reactorActive and curTemp < threshold) then
  47. reactorActive = true
  48. redstone.setOutput(reactorSide,true)
  49. elseif (reactorActive and curTemp > threshold) then
  50. reactorActive = false
  51. redstone.setOutput(reactorSide,false)
  52. end
  53. os.sleep(0.05)
  54. end
  55. end
  56.  
  57. parallel.waitForAny(listener, MainFunct)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement