Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local w, h = term.getSize()
- function usercp(user, pass)
- options = {[0] = "Log out", [1] = "Change Password", [2] = "Back to Reactor Access Panel"}
- selected = 0
- maxoptions = 2
- checkingkey = true
- while checkingkey do
- term.clear()
- term.setCursorPos(1,1)
- i=0
- repeat
- write("-")
- i=i+1
- until i == (w-1)
- workstring = "NeXTBattle User CP"
- term.setCursorPos(((w/2)-(string.len(workstring)/2)),2)
- write(workstring)
- term.setCursorPos(1,3)
- i=0
- repeat
- write("-")
- i=i+1
- until i == (w-1)
- term.setCursorPos(1,16)
- i=0
- repeat
- write("-")
- i=i+1
- until i == (w-1)
- workstring = "Welcome to the User CP, "..user.."!"
- term.setCursorPos(((w/2)-(string.len(workstring)/2)),17)
- write(workstring)
- term.setCursorPos(1,18)
- i=0
- repeat
- write("-")
- i=i+1
- until i == (w-1)
- workstring = "[--> "..options[selected].." <--]"
- term.setCursorPos(((w/2)-(string.len(workstring)/2)),(h/2))
- write(workstring)
- subselect = 0
- if selected == 0 then subselect = maxoptions else subselect = selected-1 end
- workstring = options[subselect]
- term.setCursorPos(((w/2)-(string.len(workstring)/2)),(h/2)-2)
- write(workstring)
- if selected == maxoptions then subselect = 0 else subselect = selected+1 end
- workstring = options[subselect]
- term.setCursorPos(((w/2)-(string.len(workstring)/2)),(h/2)+2)
- write(workstring)
- local sEvent, param = os.pullEvent("key")
- if(sEvent == "key") then
- if(param == 200) then
- if selected == 0 then selected = maxoptions else selected = selected-1 end
- end
- if(param == 208) then
- if selected == maxoptions then selected = 0 else selected = selected+1 end
- end
- if(param == 28) then
- if selected == 2 then
- checkingkey = false;
- mainmenu(user, pass)
- end
- if selected == 1 then
- term.clear()
- term.setCursorPos(1,1)
- i=0
- repeat
- write("-")
- i=i+1
- until i == (w-1)
- workstring = "NeXTBattle User CP"
- term.setCursorPos(((w/2)-(string.len(workstring)/2)),2)
- write(workstring)
- term.setCursorPos(1,3)
- i=0
- repeat
- write("-")
- i=i+1
- until i == (w-1)
- workstring = "Please enter your current password:"
- term.setCursorPos(((w/2)-(string.len(workstring)/2)),(h/2)-2)
- write(workstring)
- term.setCursorPos(((w/2)-(string.len(workstring)/2)),(h/2)-1)
- currentpass = read("*")
- if currentpass ~= pass then
- term.clear()
- term.setCursorPos(1,1)
- i=0
- repeat
- write("-")
- i=i+1
- until i == (w-1)
- workstring = "NeXTBattle User CP"
- term.setCursorPos(((w/2)-(string.len(workstring)/2)),2)
- write(workstring)
- term.setCursorPos(1,3)
- i=0
- repeat
- write("-")
- i=i+1
- until i == (w-1)
- workstring = "Incorrect Password!"
- term.setCursorPos(((w/2)-(string.len(workstring)/2)),(h/2)-2)
- write(workstring)
- sleep(2)
- else
- term.clear()
- term.setCursorPos(1,1)
- i=0
- repeat
- write("-")
- i=i+1
- until i == (w-1)
- workstring = "NeXTBattle User CP"
- term.setCursorPos(((w/2)-(string.len(workstring)/2)),2)
- write(workstring)
- term.setCursorPos(1,3)
- i=0
- repeat
- write("-")
- i=i+1
- until i == (w-1)
- workstring = "Please enter your new password:"
- term.setCursorPos(((w/2)-(string.len(workstring)/2)),(h/2)-2)
- write(workstring)
- term.setCursorPos(((w/2)-(string.len(workstring)/2)),(h/2)-1)
- newpass = read("*")
- term.clear()
- term.setCursorPos(1,1)
- i=0
- repeat
- write("-")
- i=i+1
- until i == (w-1)
- workstring = "NeXTBattle User CP"
- term.setCursorPos(((w/2)-(string.len(workstring)/2)),2)
- write(workstring)
- term.setCursorPos(1,3)
- i=0
- repeat
- write("-")
- i=i+1
- until i == (w-1)
- workstring = "Please confirm your new password:"
- term.setCursorPos(((w/2)-(string.len(workstring)/2)),(h/2)-2)
- write(workstring)
- term.setCursorPos(((w/2)-(string.len(workstring)/2)),(h/2)-1)
- newconfpass = read("*")
- if newconfpass == newpass then
- rednet.send(56, "~"..user.."~"..newpass)
- id, msg = rednet.receive()
- if msg == "ok" then
- term.clear()
- term.setCursorPos(1,1)
- i=0
- repeat
- write("-")
- i=i+1
- until i == (w-1)
- workstring = "NeXTBattle User CP"
- term.setCursorPos(((w/2)-(string.len(workstring)/2)),2)
- write(workstring)
- term.setCursorPos(1,3)
- i=0
- repeat
- write("-")
- i=i+1
- until i == (w-1)
- workstring = "Your password has been changed!"
- term.setCursorPos(((w/2)-(string.len(workstring)/2)),(h/2)-2)
- write(workstring)
- sleep(2)
- else
- term.clear()
- term.setCursorPos(1,1)
- i=0
- repeat
- write("-")
- i=i+1
- until i == (w-1)
- workstring = "NeXTBattle User CP"
- term.setCursorPos(((w/2)-(string.len(workstring)/2)),2)
- write(workstring)
- term.setCursorPos(1,3)
- i=0
- repeat
- write("-")
- i=i+1
- until i == (w-1)
- workstring = "An error occurred!"
- term.setCursorPos(((w/2)-(string.len(workstring)/2)),(h/2)-2)
- write(workstring)
- sleep(2)
- end
- else
- term.clear()
- term.setCursorPos(1,1)
- i=0
- repeat
- write("-")
- i=i+1
- until i == (w-1)
- workstring = "NeXTBattle User CP"
- term.setCursorPos(((w/2)-(string.len(workstring)/2)),2)
- write(workstring)
- term.setCursorPos(1,3)
- i=0
- repeat
- write("-")
- i=i+1
- until i == (w-1)
- workstring = "The passwords didn't match!"
- term.setCursorPos(((w/2)-(string.len(workstring)/2)),(h/2)-2)
- write(workstring)
- sleep(2)
- end
- end
- selected = 0
- end
- if selected == 0 then
- term.clear()
- term.setCursorPos(1,1)
- i=0
- repeat
- write("-")
- i=i+1
- until i == (w-1)
- workstring = "NeXTBattle Nuclear Access"
- term.setCursorPos(((w/2)-(string.len(workstring)/2)),2)
- write(workstring)
- term.setCursorPos(1,3)
- i=0
- repeat
- write("-")
- i=i+1
- until i == (w-1)
- workstring = "Logging out..."
- term.setCursorPos(((w/2)-(string.len(workstring)/2)),(h/2)-2)
- write(workstring)
- sleep(1)
- os.reboot()
- end
- end
- end
- sleep(0.2)
- end
- end
- function mainmenu(user, pass)
- options = {[0] = "Log out", [1] = "Open Reactor Control Room", [2] = "Open Reactor Maintenance Access", [3] = "Open EU Storage Room", [4] = "Open Server Center Access"}
- maxoptions = 4
- selected = 0
- checkingkey = true
- while checkingkey do
- term.clear()
- term.setCursorPos(1,1)
- i=0
- repeat
- write("-")
- i=i+1
- until i == (w-1)
- workstring = "NeXTBattle Nuclear Access"
- term.setCursorPos(((w/2)-(string.len(workstring)/2)),2)
- write(workstring)
- term.setCursorPos(1,3)
- i=0
- repeat
- write("-")
- i=i+1
- until i == (w-1)
- term.setCursorPos(1,16)
- i=0
- repeat
- write("-")
- i=i+1
- until i == (w-1)
- workstring = "Successfully logged in"
- term.setCursorPos(1,17)
- write(workstring)
- workstring = "U - UserCP"
- term.setCursorPos(w-string.len(workstring),17)
- write(workstring)
- term.setCursorPos(1,18)
- i=0
- repeat
- write("-")
- i=i+1
- until i == (w-1)
- workstring = "[--> "..options[selected].." <--]"
- term.setCursorPos(((w/2)-(string.len(workstring)/2)),(h/2))
- write(workstring)
- subselect = 0
- if selected == 0 then subselect = maxoptions else subselect = selected-1 end
- workstring = options[subselect]
- term.setCursorPos(((w/2)-(string.len(workstring)/2)),(h/2)-2)
- write(workstring)
- if selected == maxoptions then subselect = 0 else subselect = selected+1 end
- workstring = options[subselect]
- term.setCursorPos(((w/2)-(string.len(workstring)/2)),(h/2)+2)
- write(workstring)
- local sEvent, param = os.pullEvent("key")
- if(sEvent == "key") then
- if(param == 22) then
- checkingkey = false
- usercp(user, pass)
- end
- if(param == 200) then
- if selected == 0 then selected = maxoptions else selected = selected-1 end
- end
- if(param == 208) then
- if selected == maxoptions then selected = 0 else selected = selected+1 end
- end
- if(param == 28) then
- if selected == 1 then
- term.clear()
- term.setCursorPos(1,1)
- i=0
- repeat
- write("-")
- i=i+1
- until i == (w-1)
- workstring = "NeXTBattle Nuclear Access"
- term.setCursorPos(((w/2)-(string.len(workstring)/2)),2)
- write(workstring)
- term.setCursorPos(1,3)
- i=0
- repeat
- write("-")
- i=i+1
- until i == (w-1)
- workstring = "Opening the Reactor Control Room..."
- term.setCursorPos(((w/2)-(string.len(workstring)/2)),(h/2)-2)
- write(workstring)
- rednet.send(25, "L1")
- rednet.receive()
- sleep(5)
- rednet.send(25, "L1")
- rednet.receive()
- selected = 0
- end
- if selected == 2 then
- term.clear()
- term.setCursorPos(1,1)
- i=0
- repeat
- write("-")
- i=i+1
- until i == (w-1)
- workstring = "NeXTBattle Nuclear Access"
- term.setCursorPos(((w/2)-(string.len(workstring)/2)),2)
- write(workstring)
- term.setCursorPos(1,3)
- i=0
- repeat
- write("-")
- i=i+1
- until i == (w-1)
- workstring = "Opening the Reactor Maintenance Access..."
- term.setCursorPos(((w/2)-(string.len(workstring)/2)),(h/2)-2)
- write(workstring)
- rednet.send(25, "L4")
- rednet.receive()
- sleep(5)
- rednet.send(25, "L4")
- rednet.receive()
- selected = 0
- end
- if selected == 3 then
- term.clear()
- term.setCursorPos(1,1)
- i=0
- repeat
- write("-")
- i=i+1
- until i == (w-1)
- workstring = "NeXTBattle Nuclear Access"
- term.setCursorPos(((w/2)-(string.len(workstring)/2)),2)
- write(workstring)
- term.setCursorPos(1,3)
- i=0
- repeat
- write("-")
- i=i+1
- until i == (w-1)
- workstring = "Opening the EU Storage Area..."
- term.setCursorPos(((w/2)-(string.len(workstring)/2)),(h/2)-2)
- write(workstring)
- rednet.send(25, "L2")
- rednet.receive()
- sleep(5)
- rednet.send(25, "L2")
- rednet.receive()
- selected = 0
- end
- if selected == 4 then
- term.clear()
- term.setCursorPos(1,1)
- i=0
- repeat
- write("-")
- i=i+1
- until i == (w-1)
- workstring = "NeXTBattle Nuclear Access"
- term.setCursorPos(((w/2)-(string.len(workstring)/2)),2)
- write(workstring)
- term.setCursorPos(1,3)
- i=0
- repeat
- write("-")
- i=i+1
- until i == (w-1)
- workstring = "Opening the Server Center Access..."
- term.setCursorPos(((w/2)-(string.len(workstring)/2)),(h/2)-2)
- write(workstring)
- rednet.send(25, "L8")
- rednet.receive()
- sleep(5)
- rednet.send(25, "L8")
- rednet.receive()
- selected = 0
- end
- if selected == 0 then
- term.clear()
- term.setCursorPos(1,1)
- i=0
- repeat
- write("-")
- i=i+1
- until i == (w-1)
- workstring = "NeXTBattle Nuclear Access"
- term.setCursorPos(((w/2)-(string.len(workstring)/2)),2)
- write(workstring)
- term.setCursorPos(1,3)
- i=0
- repeat
- write("-")
- i=i+1
- until i == (w-1)
- workstring = "Logging out..."
- term.setCursorPos(((w/2)-(string.len(workstring)/2)),(h/2)-2)
- write(workstring)
- sleep(1)
- os.reboot()
- end
- end
- end
- sleep(0.2)
- end
- end
- term.clear()
- term.setCursorPos(1,1)
- i=0
- repeat
- write("-")
- i=i+1
- until i == (w-1)
- workstring = "NeXTBattle Nuclear Access"
- term.setCursorPos(((w/2)-(string.len(workstring)/2)),2)
- write(workstring)
- term.setCursorPos(1,3)
- i=0
- repeat
- write("-")
- i=i+1
- until i == (w-1)
- term.setCursorPos(1,16)
- i=0
- repeat
- write("-")
- i=i+1
- until i == (w-1)
- workstring = "Please login for reactor access"
- term.setCursorPos(((w/2)-(string.len(workstring)/2)),17)
- write(workstring)
- term.setCursorPos(1,18)
- i=0
- repeat
- write("-")
- i=i+1
- until i == (w-1)
- workstring = "Please enter your username:"
- term.setCursorPos(((w/2)-(string.len(workstring)/2)),(h/2)-2)
- write(workstring)
- term.setCursorPos(((w/2)-(string.len(workstring)/2)),(h/2)-1)
- user = read()
- term.clear()
- term.setCursorPos(1,1)
- local w, h = term.getSize()
- i=0
- repeat
- write("-")
- i=i+1
- until i == (w-1)
- workstring = "NeXTBattle Nuclear Access"
- term.setCursorPos(((w/2)-(string.len(workstring)/2)),2)
- write(workstring)
- term.setCursorPos(1,3)
- i=0
- repeat
- write("-")
- i=i+1
- until i == (w-1)
- term.setCursorPos(1,16)
- i=0
- repeat
- write("-")
- i=i+1
- until i == (w-1)
- workstring = "Please login for reactor access"
- term.setCursorPos(((w/2)-(string.len(workstring)/2)),17)
- write(workstring)
- term.setCursorPos(1,18)
- i=0
- repeat
- write("-")
- i=i+1
- until i == (w-1)
- workstring = "Please enter your password:"
- term.setCursorPos(((w/2)-(string.len(workstring)/2)),(h/2)-2)
- write(workstring)
- term.setCursorPos(((w/2)-(string.len(workstring)/2)),(h/2)-1)
- pass = read("*")
- rednet.open("back")
- rednet.send(56, user.."~"..pass)
- id, msg = rednet.receive()
- if id==56 and (msg=="true" or msg=="root") then
- term.clear()
- term.setCursorPos(1,1)
- i=0
- repeat
- write("-")
- i=i+1
- until i == (w-1)
- workstring = "NeXTBattle Nuclear Access"
- term.setCursorPos(((w/2)-(string.len(workstring)/2)),2)
- write(workstring)
- term.setCursorPos(1,3)
- i=0
- repeat
- write("-")
- i=i+1
- until i == (w-1)
- workstring = "Welcome "..user.."!"
- term.setCursorPos(((w/2)-(string.len(workstring)/2)),(h/2)-2)
- write(workstring)
- workstring = "Logging in..."
- term.setCursorPos(((w/2)-(string.len(workstring)/2)),(h/2)-1)
- write(workstring)
- sleep(1)
- mainmenu(user, pass)
- else
- term.clear()
- term.setCursorPos(1,1)
- i=0
- repeat
- write("-")
- i=i+1
- until i == (w-1)
- workstring = "NeXTBattle Nuclear Access"
- term.setCursorPos(((w/2)-(string.len(workstring)/2)),2)
- write(workstring)
- term.setCursorPos(1,3)
- i=0
- repeat
- write("-")
- i=i+1
- until i == (w-1)
- if msg == nil then workstring = "Could not connect to the login server!" else workstring = "Invalid Details!" end
- term.setCursorPos(((w/2)-(string.len(workstring)/2)),(h/2)-2)
- write(workstring)
- sleep(3)
- os.reboot()
- end
Add Comment
Please, Sign In to add comment