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 rCreateFile(User,y)
- cleer()
- 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)
- internalNum2 = internalNum2 + 1
- end
- term.setCursorPos(1,y)
- term.setBackgroundColor(colors.gray)
- write(" ")
- term.setCursorPos(1,y)
- local input = read()
- local file = fs.open("saves/"..User.."/Desktop/"..input,"w")
- file.close()
- end
- function rRenameFile(User,y,fName)
- cleer()
- 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)
- internalNum2 = internalNum2 + 1
- end
- term.setCursorPos(1,y)
- term.setBackgroundColor(colors.gray)
- write(" ")
- term.setCursorPos(1,y)
- local input = read()
- fs.move("saves/"..User.."/Desktop/"..fName,"saves/"..User.."/Desktop/"..input)
- end
- function rOpt(User,x,y,fName)
- term.setCursorPos(x+1,y)
- term.setBackgroundColor(colors.gray)
- write("New ")
- term.setCursorPos(x+1,y+1)
- write("Rename")
- term.setCursorPos(x+1,y+2)
- write("Delete")
- local event,button,x1,y1 = os.pullEvent("mouse_click")
- if x1 >= x+1 and x1 <= x+7 and y1 == y then
- rCreateFile(User,y)
- elseif x1 >= x+1 and x1 <= x+7 and y1 == y+1 then
- rRenameFile(User,y,fName)
- elseif x1 >= x+1 and x1 <= x+7 and y1 == y+2 then
- fs.delete("saves/"..User.."/Desktop/"..fName)
- end
- end
- function rFile(fName,User)
- cleer()
- local tContents = {}
- local internalNum = 1
- local file = fs.open("saves/"..User.."/Desktop/"..fName,"r")
- for line in file.readLine do
- table.insert(tContents,internalNum,line)
- print(tContents[internalNum])
- internalNum = internalNum + 1
- end
- file.close()
- term.setCursorPos(1,19)
- write(">Back")
- local event,button,x,y = os.pullEvent("mouse_click")
- if y < 19 then
- term.setCursorPos(1,y)
- term.setBackgroundColor(colors.gray)
- term.write(" ")
- term.setCursorPos(1,y)
- local input = read()
- table.remove(tContents,y)
- table.insert(tContents,y,input)
- local file2 = fs.open("saves/"..User.."/Desktop/"..fName,"w")
- for i,v in ipairs(tContents) do
- file2.writeLine(v)
- end
- file2.close()
- rFile(fName,User)
- end
- 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 <= string.len("Create Account") and y == 19 then
- cleer()
- makeAcc()
- elseif 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
- table.insert(fileContents,internalNum2,file2)
- print(fileContents[internalNum2])
- internalNum2 = internalNum2 + 1
- end
- term.setCursorPos(1,19)
- write("Sign Off")
- local event,button,x,y = os.pullEvent("mouse_click")
- if button == 1 and y < 19 then
- local fName = tostring(fileContents[y])
- rFile(fName,User)
- elseif button == 2 and y < 19 then
- local fName = tostring(fileContents[y])
- rOpt(User,x,y,fName)
- elseif button == 1 and y == 19 then
- os.reboot()
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement