Advertisement
s3ptum

reactor timer

Dec 10th, 2013
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.43 KB | None | 0 0
  1. --Load Sensor API
  2. os.loadAPI("ocs/apis/sensor")
  3.  
  4. --Wrap Monitor
  5. mon = peripheral.wrap("monitor_13")
  6.  
  7. --Find Sensor
  8. sensepwr = sensor.wrap("left")
  9. senseheat = sensor.wrap("bottom")
  10.  
  11. --Redirect to Monitor
  12. term.redirect(mon)
  13.  
  14. --Print Heat
  15. function printHeat()
  16.     print(reactorheat.HeatPercentage)
  17.     end
  18.  
  19. --Find the heat
  20. function FindHeat()
  21.   reactorheat = senseheat.getTargetDetails("0,2,2")
  22. end
  23.  
  24. --Find the Power
  25. function FindPower()
  26.   reactorpwr = sensepwr.getTargetDetails("0,3,1")
  27. end
  28.  
  29. --Update Monitor power
  30. function UpdateMonPwr()
  31.     os.startTimer(1)
  32.     local event = os.pullEvent()
  33.     if event == "timer" then
  34.   term.setTextColor(colors.white)
  35.   term.setCursorPos(1,1)
  36.   print(reactorpwr.EnergySunken)
  37.  end
  38.  
  39.  
  40.    
  41.  
  42.  
  43. --Update Monitor Heat
  44.  function UpdateMonHeat()
  45.   term.setCursorPos(1,4)
  46.   if reactorheat.HeatPercentage <= 33 then
  47.     term.setTextColor(colors.lime)
  48.     rs.setOutput("back", true)
  49.     printHeat()
  50.   elseif reactorheat.HeatPercentage >= 33 and reactorheat.HeatPercentage <= 66 then
  51.     term.setTextColor(colors.yellow)
  52.     printHeat()
  53.   elseif reactorheat.HeatPercentage >= 66 and reactorheat.HeatPercentage <= 75 then
  54.     term.setTextColor(colors.red)
  55.     printHeat()
  56.   elseif reactorheat.HeatPercentage >= 75 then
  57.     term.setTextColor(colors.red)
  58.     printHeat()
  59.     rs.setOutput("back", false)
  60.   end
  61.   end
  62.  
  63. while true do
  64.   FindPower()
  65.   FindHeat()
  66.   UpdateMonPwr()
  67.   sleep(.5)
  68.   UpdateMonHeat()
  69.   end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement