Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --Made by Esbenmine
- term.clear()
- term.setCursorPos(1,1)
- ServerID = 1
- Start = true
- xPos, yPos = term.getSize()
- term.setBackgroundColor(colors.white)
- term.setTextColor(colors.blue)
- term.clear()
- rednet.open("top")
- Menu = function()
- term.clear()
- term.setCursorPos(1,1)
- print("Type 'help'")
- repeat
- term.setCursorPos(1,1)
- print("Type 'help'")
- term.setCursorPos(1,yPos)
- command = read()
- if command:upper() == "UPLOAD" then
- term.setCursorPos(1, yPos-1)
- print("Enter filename")
- term.setCursorPos(1, yPos)
- FileName = read()
- rednet.send(ServerID, "@Upload")
- rednet.send(ServerID, Uname)
- rednet.send(ServerID, Pass)
- rednet.send(ServerID, FileName)
- id, Message = rednet.receive()
- if id == ServerID then
- if Message == "@File Exists" then
- term.setCursorPos(1,(yPos-1))
- print("File already exists.")
- elseif Message == "@WP" then
- term.clear()
- term.setCursorPos((xPos/2 - #"You are not logged in."),(yPos/2))
- print("You are not logged in.")
- os.reboot()
- elseif Message == "@StartUL" then
- if fs.exists(FileName) then
- rednet.send(ServerID, "@File Exists")
- file = fs.open(FileName,"r")
- FileLines = file.readAll()
- rednet.send(ServerID,FileLines)
- file.close()
- else
- rednet.send(ServerID, "@CancelUL")
- term.setCursorPos(1,(yPos-1))
- print("File do not exists on your computer.")
- end
- end
- end
- elseif command:upper() == "HELP" then
- term.setCursorPos(1,(yPos-1))
- print("'Upload' / 'Ul' Upload file to Goggle Cloud.")
- term.setCursorPos(1,(yPos-2))
- print("'Download' Download file from Goggle Cloud.")
- term.setCursorPos(1,(yPos-3))
- print("'ls' / 'list' List of your Goggle Cloud files.")
- term.setCursorPos(1,(yPos-4))
- print("'rm' / 'remove' Remove a file from your Goggle Cloud.")
- elseif command:upper() == "DOWNLOAD" then
- term.setCursorPos(1,(yPos-1))
- print("File to download: ")
- term.setCursorPos(1,yPos)
- FileName = read()
- if fs.exists(FileName) then
- term.setCursorPos(1,(yPos-1))
- print("File already exists on your computer.")
- else
- rednet.send(ServerID, "@Download")
- rednet.send(ServerID, Uname)
- rednet.send(ServerID, Pass)
- rednet.send(ServerID, FileName)
- id, Continue = rednet.receive()
- if id == ServerID then
- if Continue == true then
- id, Message = rednet.receive()
- if id == ServerID then
- if Message == "@File exists" then
- id, Lines = rednet.receive()
- if id == ServerID then
- file = fs.open(FileName,"w")
- file.write(Lines)
- file.close()
- term.setCursorPos(1,(yPos-1))
- print(FileName," downloaded sucessful.")
- else
- rednet.send(id, "Wrong ID")
- end
- elseif Message == "@File do not exists" then
- term.setCursorPos(1,(yPos-1))
- print("File do not exists.")
- end
- end
- elseif Continue == false then
- term.setCursorPos(1,yPos)
- print("You are not logged in.")
- end
- else
- rednet.send(id, "Wrong ID")
- end
- end
- elseif command:upper() == "LS" or command:upper() == "LIST" then
- rednet.send(ServerID, "@List")
- rednet.send(ServerID, Uname)
- rednet.send(ServerID, Pass)
- id, Login = rednet.receive()
- if id == ServerID then
- if Login == true then
- id, Files = rednet.receive()
- if id == ServerID then
- term.setCursorPos(1,(yPos-1-table.getn(Files)))
- print("You have ",table.getn(Files)," file(s) in Goggle Cloud.")
- for i = 1, table.getn(Files) do
- term.setCursorPos(1,(yPos-i))
- print(Files[i]," ")
- end
- else
- rednet.send(id, "Wrong ID")
- end
- else
- term.setCursorPos(1,(yPos-1))
- print("You are not logged in.")
- end
- end
- elseif command:upper() == "DELETE" or command:upper() == "RM" then
- term.setCursorPos(1,(yPos-1))
- print("File to delete: ")
- FileName = read()
- rednet.send(ServerID, "@Delete")
- rednet.send(ServerID, Uname)
- rednet.send(ServerID, Pass)
- id, Login = rednet.receive()
- if id == ServerID then
- if Login == true then
- rednet.send(ServerID, FileName)
- id, Exists = rednet.receive()
- if id == ServerID then
- if Exists == true then
- term.setCursorPos(1,(yPos-1))
- print(FileName," deleted sucessful.")
- elseif Exists == false then
- term.setCursorPos(1,(yPos-1))
- print("File do not exists.")
- end
- else
- rednet.send(id, "Wrong ID")
- end
- elseif Login == false then
- term.setCursorPos(1,(yPos-1))
- print("You are not logged in.")
- end
- else
- rednet.send(id, "Wrong ID")
- end
- end
- until Start == false
- end
- Login = function()
- repeat
- term.clear()
- term.setCursorPos((xPos/2 - #"-----------"/2),2)
- print("-----------")
- term.setCursorPos((xPos/2 - #"{Google Cloud}"/2),3)
- print("{Goggle Cloud}")
- term.setCursorPos((xPos/2 - #"-----------"/2),4)
- print("-----------")
- term.setCursorPos((xPos/2 - #"Username:"/2),7)
- write("Username: ")
- term.setCursorPos((xPos/2 - #"Password:"/2),8)
- write("Password: ")
- term.setCursorPos((xPos/2 + #"Username: "/2),7)
- Uname = read()
- term.setCursorPos((xPos/2 + #"Password: "/2),8)
- Pass = read("*")
- rednet.send(ServerID, "@Pass")
- rednet.send(ServerID, Uname)
- rednet.send(ServerID, Pass)
- id, Answer = rednet.receive()
- if Answer == "@CP" then
- Menu()
- elseif Answer == "@WP" then
- term.setCursorPos((xPos/2 - #"Incorrect Password"/2),10)
- print("Incorrect Password")
- sleep(1)
- end
- until Answer == "@CP"
- end
- Login()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement