Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function cleer()
- term.setCursorPos(1,1)
- term.setBackgroundColor(colors.black)
- term.setTextColor(colors.white)
- term.clear()
- end
- if fs.exists("saves") then
- print("yes")
- sleep(1)
- else
- fs.makeDir("saves")
- fs.makeDir("saves/OS")
- fs.open("saves/OS/accounts","w")
- print("no but i made one")
- sleep(1)
- end
- function rFile(fName,User)
- cleer()
- local file = fs.open("saves/"..User.."/Desktop/"..fName,"r")
- for line in file.readLine do
- print(line)
- end
- file.close()
- term.setCursorPos(1,19)
- write(">Back")
- local event,button,x,y = os.pullEvent("mouse_click")
- end
- function login(User)
- cleer()
- write("Password: ")
- local Pass = read("*")
- local file = fs.open("saves/"..User.."/info","r")
- inputPass = file.readLine()
- file.close()
- cleer()
- if inputPass == Pass then
- local cUserFile = fs.open("saves/OS/cUser","w")
- cUserFile.writeLine(User)
- cUserFile.close()
- else
- cleer()
- term.setTextColor(colors.red)
- write("Incorrect.")
- sleep(2)
- os.reboot()
- end
- end
- function makeAcc()
- cleer()
- write("Username: ")
- local Username = read()
- if fs.exists("saves/"..Username) then
- cleer()
- term.setTextColor(colors.red)
- write("Account already exists")
- os.reboot()
- end
- term.setCursorPos(1,2)
- write("Password: ")
- local Pass = read("*")
- fs.makeDir("saves/"..Username)
- fs.makeDir("saves/"..Username.."/desktop")
- local readmeFile = fs.open("saves/"..Username.."/desktop/ReadMe","w")
- local tContents = {"You are currently viewing a text file","Press the back button to go back","Once you are back you can","right click to get more options"}
- for i,v in ipairs(tContents) do
- readmeFile.writeLine(v)
- end
- readmeFile.close()
- local file = fs.open("saves/"..Username.."/info","w")
- file.writeLine(Pass)
- file.close()
- cleer()
- write("Rebooting")
- sleep(1)
- os.reboot()
- end
- cleer()
- local width, height = term.getSize()
- term.setCursorPos(math.floor(width-string.len("Welcome"))/2,1)
- print("Welcome")
- term.setCursorPos(1,2)
- local FileList = fs.list("saves")
- local menuContents = {}
- local internalNum = 1
- for _,file in ipairs(FileList) do
- print(file)
- table.insert(menuContents, internalNum, file)
- internalNum = internalNum + 1
- end
- term.setCursorPos(1,19)
- write("Create Account")
- local event,button,x,y = os.pullEvent("mouse_click")
- if x >= 1 and x <= string.len("Create Account") and y == 19 then
- cleer()
- makeAcc()
- elseif x >=1 and x <= string.len(menuContents[y-1]) then
- local User = tostring(menuContents[y-1])
- if User == "OS" then
- cleer()
- term.setTextColor(colors.red)
- write("Access Denied.")
- sleep(2)
- os.reboot()
- else
- login(User)
- end
- end
- while true do
- cleer()
- local cUser = fs.open("saves/OS/cUser","r")
- local User = cUser.readLine()
- cUser.close()
- local fileList = fs.list("saves/"..User.."/desktop")
- local fileContents = {}
- local internalNum2 = 1
- for _,file2 in ipairs(fileList) do
- print(file2)
- table.insert(fileContents,internalNum2,file2)
- end
- local event,button,x,y = os.pullEvent("mouse_click")
- if x <= string.len(fileContents[y]) and button == 1 then
- local fName = tostring(fileContents[y])
- rFile(fName,User)
- elseif button == 2 then
- print(2)
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement