slay_mithos

Untitled

Apr 26th, 2014
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.59 KB | None | 0 0
  1. local r --reactor
  2. local m --monitor
  3.  
  4. function startup()
  5.     r = peripheral.wrap('back')
  6.     m = peripheral.wrap('monitor_0')
  7.  
  8. --~     m.setTextScale(0.5)
  9.     term.clear()
  10.     term.setCursorPos(1, 1)
  11.     print ('Redirecting to monitor...')
  12.     term.redirect(m)
  13. end
  14.  
  15. function displayData(data)
  16.     term.clear()
  17.     term.setCursorPos(1, 1)
  18.    
  19.     print("Active: ".. tostring(data["active"]))
  20.     print("Fuel: "..tostring(data["fuel"]).."mb")
  21.     print("Fuel Temp: "..tostring(data["fuelTemp"]))
  22.     print("Casing Temp: "..tostring(data["casingTemp"]))
  23.     print("Energy produced: "..tostring(data["energy"]))
  24.     print("Energy stored: "..tostring(data["storedEnergy"]))
  25.     print("Rod level: "..tostring(data["rodLevel"]))
  26.    
  27. end
  28.  
  29. function getData()
  30.     local data = {}
  31.    
  32.     data["active"] = r.getActive()
  33.     data["fuel"] = r.getFuelAmount()
  34.     data["fuelTemp"] = r.getFuelTemperature()
  35.     data["casingTemp"] = r.getCasingTemperature()
  36.     data["energy"] = r.getEnergyProducedLastTick()
  37.     data["storedEnergy"] = r.getEnergyStored()
  38.     data["rodLevel"] = r.getControlRodLevel(1)
  39.    
  40.     return data
  41. end
  42.  
  43. function controlRods(data)
  44.     local rodLevel = data["rodLevel"]
  45.     local fuelTemp = data["fuelTemp"]
  46.     local storedEnergy = data["storedEnergy"]
  47.     local active = data["active"]
  48.    
  49.     if storedEnergy > 8000000 then
  50.         r.setActive(false)
  51.     elseif not active and storedEnergy < 200000 then
  52.         r.setActive(true)
  53.     elseif active and fuelTemp > 1000 then
  54.         r.setAllControlRodLevels(rodLevel-1)
  55.     elseif active and fuelTemp < 800 then
  56.     end
  57. end
  58.  
  59.  
  60. startup()
  61. while true do
  62.     local data = getData()
  63.     controlRods(data)
  64.    
  65.     displayData(data)
  66.    
  67.     os.sleep(1)
  68. end
Advertisement
Add Comment
Please, Sign In to add comment