lewile1

ReactorControl

Jan 12th, 2015
214
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.13 KB | None | 0 0
  1. reactor = peripheral.wrap("back")
  2. monitor = peripheral.wrap("monitor_0")
  3.  
  4. --function for fuel info
  5. function fuelInfo(mon, br, x, y)
  6.    mon.setCursorPos(x, y)
  7.    mon.setTextColor(colors.white)
  8.    mon.write("Fuel Level:")
  9.    mon.setCursorPos(x, y+1)
  10.    mon.setTextColor(colors.yellow)
  11.    mon.write((br.getFuelAmount()/br.getFuelAmountMax()*100).."%")
  12. end
  13.  
  14. -- total charge info
  15. function chargeInfo(mon, br, x, y)
  16.    mon.setCursorPos(x,y)
  17.    mon.setTextColor(colors.white)
  18.    mon.write("Current Charge:")
  19.    mon.setCursorPos(x,y+1)
  20.    mon.setTextColor(colors.yellow)
  21.    mon.write(br.getEnergyStored().." RF")
  22. end
  23.  
  24. -- reactor status on/off
  25. function reactorStatus(mon, br, x, y)
  26.    mon.setCursorPos(x,y)
  27.    mon.setTextColor(colors.white)
  28.    mon.write("Reactor Status:")
  29.    mon.setCursorPos(x,y+1)
  30.    mon.setTextColor(colors.yellow)
  31.    if br.getActive() then mon.write("Active") else mon.write("Inactive") end
  32. end
  33.  
  34. -- control rod controls
  35. function updateControlRods(br)
  36.    if br.getEnergyStored() <= 9500000 and br.getEnergyStored()>=0 then
  37.       br.setAllControlRodLevels(0+(br.getEnergyStored()/100000))
  38.    else
  39.       br.setAllControlRodLevels(100)
  40.    end
  41. end
  42.  
  43. -- control rod info
  44. function controlRodInfo(mon, br, x, y)
  45.     for a=0,(br.getNumberOfControlRods()-1) do
  46.        mon.setCursorPos(x, y+a)
  47.        mon.setTextColor(colors.yellow)
  48.        mon.write("ControlRod "..(a+1)..": "..(br.getControlRodLevel(a)))
  49.     end
  50. end
  51.  
  52. -- current charge information
  53. function currentCharge(mon, br, x, y)
  54.     mon.setCursorPos(x, y)
  55.     mon.setTextColor(colors.white)
  56.     mon.write("Current RF Produced:")
  57.     mon.setCursorPos(x, y+1)
  58.     mon.setTextColor(colors.yellow)
  59.     mon.write((br.getEnergyProducedLastTick()).."RF/t")
  60. end
  61.  
  62. while true do
  63.  
  64.    updateControlRods(reactor)
  65.  
  66.    monitor.clear()
  67.  
  68.    --fuel info
  69.    fuelInfo(monitor, reactor, 1, 1)  
  70.  
  71.    --charge info
  72.    chargeInfo(monitor, reactor, 1, 4)
  73.  
  74.    --reactor status
  75.    reactorStatus(monitor, reactor, 20, 1)
  76.  
  77.    --control rod info
  78.    controlRodInfo(monitor, reactor, 1, 7)
  79.  
  80.    --current charge info
  81.    currentCharge(monitor, reactor, 20, 4)
  82.  
  83.    sleep(1)
  84. end
Advertisement
Add Comment
Please, Sign In to add comment