Advertisement
BlueMond

Reactor_Control

Sep 19th, 2014
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.60 KB | None | 0 0
  1. local version = 1.1
  2. local filename = "react"
  3. local paste = "MMYCYF4U"
  4.  
  5. local function update()
  6.         local url = "http://pastebin.com/raw.php?i="..paste
  7.         local temp = http.get(url)
  8.         local ver = temp.readLine()
  9.         if tonumber(string.sub(ver, 17)) ~= version then
  10.                 fs.delete(filename)
  11.                 shell.run("pastebin get "..paste.." "..filename)
  12.                 shell.run(filename)
  13.                 return true
  14.         end
  15.         return false
  16. end
  17.  
  18. local test = update()
  19. if test == true then
  20.         error()
  21. end
  22.  
  23. rednet.open("left")
  24. os.loadAPI("ocs/apis/sensor")
  25. mon = peripheral.wrap("right")
  26. mon.setTextScale(1)
  27.  
  28. local sens = sensor.wrap("top")
  29. while true do
  30.     sleep(1)
  31.     local taken = false
  32.     local targ = sens.getTargets()
  33.     for name, det in pairs(targ) do
  34.         local details = sens.getTargetDetails(name)
  35.         if details.Name == "Reactor Chamber" and taken == false then
  36.             taken = true
  37.             shell.run("clear")
  38.             print("~Reactor Status~")
  39.             print("Active: "..tostring(details.Active))
  40.             print("Output: "..details.Output.." EU")
  41.             print("% of max Heat: "..details.HeatPercentage)
  42.             if details.HeatPercentage >= 75 then
  43.                 rednet.broadcast("reactor_off")
  44.                 print("")
  45.                 print("*Reactor has reached 75% heat and is being shutdown")
  46.             elseif details.HeatPercentage < 75 then
  47.                 if details.HeatPercentage <= 50 then
  48.                     print("")
  49.                     print("*reactor heat is stable")
  50.                     rednet.broadcast("reactor_on")
  51.                 elseif details.Active == false then
  52.                     print("")
  53.                     print("*reactor will turn back on at 50% heat")
  54.                 end
  55.             end
  56.         end
  57.     end
  58. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement