Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local FilePath = "os/System/Client"
- local PastPaths = {"os","os/System","os/System/Client"}
- local BlockedPaths = {"os/System/Security","os/System/Client/Apps","os/System/Files/.Banking","os/System/Client/Files/.UserFile","os/System/Programs","os/System/Scripts"}
- local AllowedCreate = {"os/System/Client/Files"}
- local S = 3
- local tArg = {...}
- settings.load(".settings")
- local function Clear()
- term.clear()
- term.setCursorPos(1,1)
- end
- function CUI(m) --declare function
- n=1
- local l = #m
- while true do
- term.setCursorPos(1,5)
- for i=1, #m, 1 do --traverse the table of options
- if i==n then term.clearLine() print(i, ">",m[i]) else term.clearLine() print(i, "-", m[i]) end --print them
- end
- a, b= os.pullEvent("key") --wait for keypress
- if b==keys.w and n>1 then n=n-1 end
- if b==keys.s and n<l then n=n+1 end
- if b==keys.enter then break end
- end
- return n --return the value
- end
- function Check(Items)
- if settings.get("AdminKey") == "Jta520" then
- else
- for i = 1, #Items do
- local RPath = fs.combine(FilePath,Items[i])
- for I = 1, #BlockedPaths do
- if RPath == BlockedPaths[I] then Items[i] = "Blocked" end
- end
- end
- end
- return(Items)
- end
- function CreateFile()
- Clear()
- local FileType
- print("file type")
- local options = {"lua","txt"}
- local n = CUI(options)
- if options[n] == "lua" then
- FileType = ".lua"
- else
- FileType = ".txt"
- end
- print("enter name for file")
- local input
- while true do
- local event = {os.pullEvent("key")}
- if event[2] == keys.enter then break end
- input = read()
- end
- input = input..FileType
- local P = fs.combine(FilePath, input)
- local file = fs.open(P,"w")
- file.write("new file")
- file.close()
- if FileType == ".lua" then
- shell.run("edit",P)
- else
- shell.run("os/System/Programs/TextEditor","direct",P)
- end
- DisplayPath()
- end
- function DisplayPath()
- local Paths = fs.list(FilePath)
- if FilePath == AllowedCreate[1] then
- Paths[#Paths + 1] = "create_file"
- end
- if FilePath ~= "os" then
- Paths[#Paths + 1] = "return"
- end
- Paths[#Paths + 1] = "exit"
- Clear()
- print("[",FilePath,"]")
- local APaths = Check(Paths)
- local n = CUI(APaths)
- if APaths[n] == "return" then
- FilePath = PastPaths[#PastPaths -1]
- PastPaths[#PastPaths] = nil
- DisplayPath()
- elseif APaths[n] == "exit" then
- elseif APaths[n] == "create_file" then
- CreateFile()
- DisplayPath()
- elseif APaths[n] == "Blocked" then
- DisplayPath()
- else
- FilePath = fs.combine(FilePath, APaths[n])
- if fs.isDir(FilePath) then
- PastPaths[#PastPaths + 1] = FilePath
- DisplayPath()
- else
- if fs.exists(FilePath..".lua") then
- shell.run("edit",FilePath)
- else
- shell.run("os/System/Programs/TextEditor","direct",FilePath)
- end
- FilePath = PastPaths[#PastPaths]
- DisplayPath()
- end
- end
- end
- if tArg[1] == "Show" then
- FilePath = tArg[2]
- end
- DisplayPath()
Add Comment
Please, Sign In to add comment