DeepFriedBabeez

OCCS Reactor Control

Apr 28th, 2013
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.20 KB | None | 0 0
  1. os.loadAPI("ocs/apis/graph")
  2. os.loadAPI("ocs/apis/sensor")
  3.  
  4. mySensor = sensor.wrap("top")
  5. mon = peripheral.wrap("right:red")
  6. position = "0,-1,-3"
  7. cooling = false
  8. mHeat = mySensor.getTargetDetails(position).MaxHeat
  9. time = 0
  10. initialOutputted = mySensor.getTargetDetails(position).EnergyEmitted
  11.  
  12. function cls()
  13.     term.clear()
  14.     term.setCursorPos(1,1)
  15. end
  16.  
  17. function updateHeat()
  18.     local tab = sensor.call("top", "getTargetDetails", position)
  19.     return tab.Heat
  20. end
  21.  
  22.  
  23. heatGraph = graph.new(mon, updateHeat, "Heat", {colors.lime, colors.yellow, colors.orange, colors.red}, 0, mHeat, false)
  24.  
  25. redstone.setOutput("left", true)
  26.  
  27. while true do
  28.     cls()
  29.     print("Reactor Heat: "..updateHeat())
  30.     print("Seconds Running: "..time)
  31.     print("EU Produced: "..mySensor.getTargetDetails(position).EnergyEmitted - initialOutputted)
  32.     print("Average EU/t: "..(mySensor.getTargetDetails(position).EnergyEmitted - initialOutputted) / (time*20))
  33.     heatGraph:draw()
  34.     if(updateHeat() >= 0.45*mHeat and cooling == false) then
  35.         cooling = true
  36.         redstone.setOutput("left", false)
  37.     end
  38.     if(updateHeat() <= 0.4*mHeat/3 and cooling == true) then
  39.         cooling = false
  40.         redstone.setOutput("left", true)
  41.     end
  42. sleep(1)
  43. time = time + 1
  44. end
Advertisement
Add Comment
Please, Sign In to add comment