Guest User

startup

a guest
Jul 8th, 2016
1,388
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.60 KB | None | 0 0
  1. reactor = peripheral.wrap("left")
  2. monitor = peripheral.wrap("right")
  3. monitor.setTextScale(1.5)
  4. local function roundToNthDecimal(num, n)
  5.  local mult = 10^(n or 0)
  6.  return math.floor(num * mult + 0.5) / mult
  7. end
  8. local function controlRodInsertion()
  9.     percentageEng = e / 100000
  10.     controlRodIns = (roundToNthDecimal(percentageEng, 0) - 1)
  11.     reactor.setAllControlRodLevels(controlRodIns)
  12. end
  13. local function main()
  14.   reactorOn = reactor.getActive()
  15.   os.sleep(0)
  16.     e = tonumber(reactor.getEnergyStored())
  17.     if  e > 9999999
  18.       then reactor.setActive(false)
  19.         return
  20.       elseif e < 1000000
  21.         then reactor.setActive(true)
  22.           return
  23.       end
  24.   end
  25. function monitorDisplay()
  26. monitor.setCursorPos(22,1)
  27. if e > 7500000
  28.   then monitor.setTextColor(colors.green)
  29.   elseif e < 7500000
  30.     then monitor.setTextColor(colors.yellow)
  31.   elseif e < 2500000
  32.     then monitor.setTextColor(colors.red)
  33.   end
  34. monitor.write(tostring(e))
  35. monitor.setCursorPos(24,2)
  36. monitor.setTextColor(colors.white)
  37. monitor.write(tostring(controlRodIns))
  38. monitor.setCursorPos(23,3)
  39. if reactorOn == true
  40.   then
  41.     monitor.setTextColor(colors.green)
  42.     monitor.write("ON ")
  43.    elseif reactorOn == false
  44.      then
  45.         monitor.setTextColor(colors.red)
  46.         monitor.write("OFF")
  47.    end
  48. end
  49. monitor.setTextColor(colors.white)
  50. monitor.setCursorPos(1,1)
  51. monitor.write("Current Power Level: ")
  52. monitor.setCursorPos(1,2)
  53. monitor.write("Control Rod Insertion: ")
  54. monitor.setCursorPos(1,3)
  55. monitor.write("Reactor Power Status: ")
  56. while true do
  57. main()
  58. controlRodInsertion()
  59. monitorDisplay()
  60. end
Advertisement
Add Comment
Please, Sign In to add comment