Advertisement
Guest User

Untitled

a guest
Mar 13th, 2016
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.23 KB | None | 0 0
  1. -- Functions
  2. local function cprint(text)
  3. local x,y = term.getSize()
  4. local x2,y2 = term.getCursorPos()
  5. term.setCursorPos(math.ceil((x / 2) - (text:len() / 2)), y2)
  6. write(text)
  7. end
  8.  
  9. local function clear()
  10. term.clear()
  11. term.setCursorPos(1,1)
  12. end
  13.  
  14. local function drawscreen()
  15. write(user)
  16. write("@reactor_1> ")
  17. input = read()
  18. end
  19.  
  20. local function main()
  21. drawscreen()
  22. if input == "help" then
  23. write("List of avaiable commands:\n")
  24. write(" start - Start the Reactor ( Requires Elevated Privileges )\n")
  25. write(" stop - Stop the Reactor ( Requires Elevated Privileges )\n")
  26. write(" state - Reload Reactor State \n")
  27. write(" clear - Clear the terminal\n")
  28. write(" networkoff - Disconnect the Reactor from the network ( Requires Super-Elevated Privileges )\n")
  29. write(" reboot - Reboot this computer \n")
  30. write(" version - Display the version number and copyright information\n")
  31. write(" quit - Quit the program\n")
  32. end
  33.  
  34. if input == "start" then
  35. if user == "root" or user == "heda" then
  36. rednet.open("back")
  37. rednet.broadcast("start_reactor_one")
  38. rednet.close("back")
  39. write("[")
  40. write(os.time())
  41. write("] Reactor Started\n")
  42. else
  43. write("You do not have the required privileges to perform this action.\n")
  44. end
  45. end
  46.  
  47. if input == "stop" then
  48. if user == "root" or user == "heda" then
  49. rednet.open("back")
  50. rednet.broadcast("stop_reactor_one")
  51. rednet.close("back")
  52. write("[")
  53. write(os.time())
  54. write("] Reactor Stopped\n")
  55. else
  56. write("You do not have the required privileges to perform this action.\n")
  57. end
  58. end
  59.  
  60. if input == "state" then
  61. end
  62.  
  63. if input == "networkoff" then
  64. if user == "heda" then
  65. clear()
  66. cprint("Are you SURE you wish to perform this?")
  67. write("\n")
  68. cprint("N/y>")
  69. input2 = read()
  70. if input2 == "y" then
  71. rednet.open("back")
  72. rednet.broadcast("kick_reactor_one")
  73. rednet.close("back")
  74. write("[")
  75. write(os.time())
  76. write("] Reactor Disnetworked\n")
  77. else
  78. print("Nothing was done")
  79. sleep(2)
  80. clear()
  81. end
  82. else
  83. write("You do not have the required privileges to perform this action.\n")
  84. end
  85. end
  86.  
  87. if input == "reboot" then
  88. write("Goodbye")
  89. os.reboot()
  90. end
  91.  
  92. if input == "version" then
  93. write("Hiperbolt HiperReactor 0.01\n")
  94. write("\n")
  95. write("Copyright (C) 2016 hiperbolt\n")
  96. write("\n")
  97. end
  98.  
  99. if input == "quit" then
  100. clear()
  101. write("Bye!\n")
  102. sleep(2)
  103. clear()
  104. return
  105. end
  106.  
  107. if input == "clear" then
  108. clear()
  109. end
  110.  
  111. main()
  112. end
  113.  
  114. -- init
  115. local tArgs = { ... }
  116. if #tArgs < 1 then
  117. user = "guest"
  118. clear()
  119. write("HiperReactor by Hiperbolt 0.01. Copyright (C) 2016\n")
  120. main()
  121. end
  122.  
  123. local sUser = tArgs[1]
  124. if sUser == "root" then
  125. clear()
  126. write("Enter root password:")
  127. input = read("*")
  128. if input == "root" then
  129. clear()
  130. write("HiperReactor by Hiperbolt 0.01. Copyright (C) 2016\n")
  131. user = "root"
  132. main()
  133. end
  134. elseif sUser == "heda" then
  135. clear()
  136. write("Enter heda password:")
  137. input = read("*")
  138. if input == "heda" then
  139. clear()
  140. write("HiperReactor by Hiperbolt 0.01. Copyright (C) 2016\n")
  141. user = "heda"
  142. main()
  143. end
  144. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement