Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- STARTUP --
- os.loadAPI("lokiOS/files/os/apis/lapi");
- lapi.clean(lapi.getCenter("x",9),lapi.getCenter("y"));
- textutils.slowWrite("Starting Loki OS..",40); sleep(0.5);
- local selected = 0;
- while true do
- lapi.clean();
- if selected == 0 then
- term.setCursorPos(lapi.getCenter("x",6),lapi.getCenter("y",2));
- write("> Sign Up <"); else
- term.setCursorPos(lapi.getCenter("x",4),lapi.getCenter("y",2));
- write("Sign Up");
- end
- if selected == 1 then
- term.setCursorPos(lapi.getCenter("x",6),lapi.getCenter("y",-2));
- write("> Sign In <"); else
- term.setCursorPos(lapi.getCenter("x",4),lapi.getCenter("y",-2));
- write("Sign In");
- end
- local event, key = os.pullEvent( "key" )
- if key == keys.up or key == keys.w or key == keys.left then
- if selected == 0 then selected = 1 else selected = 0 end
- elseif key == keys.down or key == keys.s or key == keys.right then
- if selected == 1 then selected = 0 else selected = 1 end
- elseif key == keys.t or key == keys.leftCtrl then
- os.reboot();
- elseif key == keys.tab then
- break;
- elseif key == keys.enter then
- if selected == 0 then
- newUser = {};
- lapi.clean(lapi.getCenter("x",9),lapi.getCenter("y"));
- textutils.slowWrite("Enter a Username:",150);
- term.setCursorPos(lapi.getCenter("x",9),lapi.getCenter("y",-1));
- local newUsername = io.read();
- lapi.clean(lapi.getCenter("x",5),lapi.getCenter("y"));
- textutils.slowWrite("Password:",150);
- term.setCursorPos(lapi.getCenter("x",5),lapi.getCenter("y",-1));
- local newPassword = read("*");
- lapi.clean(lapi.getCenter("x",9),lapi.getCenter("y"));
- textutils.slowWrite("Confirm Password:",150);
- term.setCursorPos(lapi.getCenter("x",9),lapi.getCenter("y",-1));
- local confirmNewPassword = read("*");
- if newPassword == confirmNewPassword then
- newUser["username"] = newUsername;
- newUser["password"] = newPassword;
- lapi.save(newUser,"lokiOS/files/user/"..newUsername.."/"..newUsername.."Data");
- lapi.clean(lapi.getCenter("x",8),lapi.getCenter("y"),colors.white,lapi.clc(colors.green));
- textutils.slowWrite("User registered.",64);sleep(0.75);
- else
- lapi.clean(lapi.getCenter("x",9),lapi.getCenter("y"),colors.white,lapi.clc(colors.red));
- textutils.slowWrite("Passwords not matching.",150);sleep(0.75);
- end
- elseif selected == 1 then
- lapi.clean(lapi.getCenter("x",10),lapi.getCenter("y"));
- textutils.slowWrite("Enter your Username:",150);
- term.setCursorPos(lapi.getCenter("x",10),lapi.getCenter("y",-1));
- local usernameIn = io.read();
- lapi.clean(lapi.getCenter("x",5),lapi.getCenter("y"));
- textutils.slowWrite("Password:",150);
- term.setCursorPos(lapi.getCenter("x",5),lapi.getCenter("y",-1));
- local passwordIn = read("*");
- local user = lapi.load("lokiOS/files/user/"..usernameIn.."/"..usernameIn.."Data");
- if user == 0 then
- lapi.clean(lapi.getCenter("x",10),lapi.getCenter("y"),colors.white,lapi.clc(colors.blue));
- textutils.slowWrite("User not registered.",150);sleep(0.75);
- else
- if user["username"] == usernameIn and user["password"] == passwordIn then
- lapi.clean(lapi.getCenter("x",15),lapi.getCenter("y"),colors.white,lapi.clc(colors.green));
- textutils.slowWrite("Correct login. Starting os...",60);sleep(0.75);break;
- else
- lapi.clean(lapi.getCenter("x",10),lapi.getCenter("y"),colors.white,lapi.clc(colors.red));
- textutils.slowWrite("Password incorrect.",150);sleep(0.75);
- end
- end
- end
- end
- end
- lapi.clean(1,1,colors.black,colors.white);
- shell.run("lokiOS/files/os/main");
Advertisement
Add Comment
Please, Sign In to add comment