Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Functions
- local function cprint(text)
- local x,y = term.getSize()
- local x2,y2 = term.getCursorPos()
- term.setCursorPos(math.ceil((x / 2) - (text:len() / 2)), y2)
- write(text)
- end
- local function clear()
- term.clear()
- term.setCursorPos(1,1)
- end
- local function drawscreen()
- write(user)
- write("@reactor_1> ")
- input = read()
- end
- local function main()
- drawscreen()
- if input == "help" then
- write("List of avaiable commands:\n")
- write(" start - Start the Reactor ( Requires Elevated Privileges )\n")
- write(" stop - Stop the Reactor ( Requires Elevated Privileges )\n")
- write(" state - Reload Reactor State \n")
- write(" clear - Clear the terminal\n")
- write(" networkoff - Disconnect the Reactor from the network ( Requires Super-Elevated Privileges )\n")
- write(" reboot - Reboot this computer \n")
- write(" version - Display the version number and copyright information\n")
- write(" quit - Quit the program\n")
- end
- if input == "start" then
- if user == "root" or user == "heda" then
- rednet.open("back")
- rednet.broadcast("start_reactor_one")
- rednet.close("back")
- write("[")
- write(os.time())
- write("] Reactor Started\n")
- else
- write("You do not have the required privileges to perform this action.\n")
- end
- end
- if input == "stop" then
- if user == "root" or user == "heda" then
- rednet.open("back")
- rednet.broadcast("stop_reactor_one")
- rednet.close("back")
- write("[")
- write(os.time())
- write("] Reactor Stopped\n")
- else
- write("You do not have the required privileges to perform this action.\n")
- end
- end
- if input == "state" then
- end
- if input == "networkoff" then
- if user == "heda" then
- clear()
- cprint("Are you SURE you wish to perform this?")
- write("\n")
- cprint("N/y>")
- input2 = read()
- if input2 == "y" then
- rednet.open("back")
- rednet.broadcast("kick_reactor_one")
- rednet.close("back")
- write("[")
- write(os.time())
- write("] Reactor Disnetworked\n")
- else
- print("Nothing was done")
- sleep(2)
- clear()
- end
- else
- write("You do not have the required privileges to perform this action.\n")
- end
- end
- if input == "reboot" then
- write("Goodbye")
- os.reboot()
- end
- if input == "version" then
- write("Hiperbolt HiperReactor 0.01\n")
- write("\n")
- write("Copyright (C) 2016 hiperbolt\n")
- write("\n")
- end
- if input == "quit" then
- clear()
- write("Bye!\n")
- sleep(2)
- clear()
- return
- end
- if input == "clear" then
- clear()
- end
- main()
- end
- -- init
- local tArgs = { ... }
- if #tArgs < 1 then
- user = "guest"
- clear()
- write("HiperReactor by Hiperbolt 0.01. Copyright (C) 2016\n")
- main()
- end
- local sUser = tArgs[1]
- if sUser == "root" then
- clear()
- write("Enter root password:")
- input = read("*")
- if input == "root" then
- clear()
- write("HiperReactor by Hiperbolt 0.01. Copyright (C) 2016\n")
- user = "root"
- main()
- end
- elseif sUser == "heda" then
- clear()
- write("Enter heda password:")
- input = read("*")
- if input == "heda" then
- clear()
- write("HiperReactor by Hiperbolt 0.01. Copyright (C) 2016\n")
- user = "heda"
- main()
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement