Marlingaming

CC Tweaked CCSPS Iron - File System Navigator

Jan 31st, 2022 (edited)
113
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.87 KB | None | 0 0
  1. local FilePath = "os/System/Client"
  2. local PastPaths = {"os","os/System","os/System/Client"}
  3. local BlockedPaths = {"os/System/Security","os/System/Client/Apps","os/System/Files/.Banking","os/System/Client/Files/.UserFile","os/System/Programs","os/System/Scripts"}
  4. local AllowedCreate = {"os/System/Client/Files"}
  5. local S = 3
  6. local tArg = {...}
  7. settings.load(".settings")
  8.  
  9. local function Clear()
  10. term.clear()
  11. term.setCursorPos(1,1)
  12. end
  13.  
  14. function CUI(m) --declare function
  15. n=1
  16. local l = #m
  17. while true do
  18. term.setCursorPos(1,5)
  19. for i=1, #m, 1 do --traverse the table of options
  20. if i==n then term.clearLine() print(i, ">",m[i]) else term.clearLine() print(i, "-", m[i]) end --print them
  21. end
  22. a, b= os.pullEvent("key") --wait for keypress
  23. if b==keys.w and n>1 then n=n-1 end
  24. if b==keys.s and n<l then n=n+1 end
  25. if b==keys.enter then break end
  26. end
  27. return n --return the value
  28. end
  29.  
  30. function Check(Items)
  31.  
  32. if settings.get("AdminKey") == "Jta520" then
  33.  
  34. else
  35. for i = 1, #Items do
  36. local RPath = fs.combine(FilePath,Items[i])
  37. for I = 1, #BlockedPaths do
  38. if RPath == BlockedPaths[I] then Items[i] = "Blocked" end
  39. end
  40. end
  41. end
  42. return(Items)
  43. end
  44.  
  45. function CreateFile()
  46. Clear()
  47. local FileType
  48. print("file type")
  49. local options = {"lua","txt"}
  50. local n = CUI(options)
  51. if options[n] == "lua" then
  52. FileType = ".lua"
  53. else
  54. FileType = ".txt"
  55. end
  56. print("enter name for file")
  57. local input
  58. while true do
  59. local event = {os.pullEvent("key")}
  60. if event[2] == keys.enter then break end
  61. input = read()
  62. end
  63. input = input..FileType
  64. local P = fs.combine(FilePath, input)
  65. local file = fs.open(P,"w")
  66. file.write("new file")
  67. file.close()
  68. if FileType == ".lua" then
  69. shell.run("edit",P)
  70. else
  71. shell.run("os/System/Programs/TextEditor","direct",P)
  72. end
  73. DisplayPath()
  74. end
  75.  
  76. function DisplayPath()
  77. local Paths = fs.list(FilePath)
  78. if FilePath == AllowedCreate[1] then
  79. Paths[#Paths + 1] = "create_file"
  80. end
  81. if FilePath ~= "os" then
  82. Paths[#Paths + 1] = "return"
  83. end
  84. Paths[#Paths + 1] = "exit"
  85. Clear()
  86. print("[",FilePath,"]")
  87. local APaths = Check(Paths)
  88. local n = CUI(APaths)
  89. if APaths[n] == "return" then
  90. FilePath = PastPaths[#PastPaths -1]
  91. PastPaths[#PastPaths] = nil
  92. DisplayPath()
  93. elseif APaths[n] == "exit" then
  94.  
  95. elseif APaths[n] == "create_file" then
  96. CreateFile()
  97. DisplayPath()
  98. elseif APaths[n] == "Blocked" then
  99. DisplayPath()
  100. else
  101. FilePath = fs.combine(FilePath, APaths[n])
  102. if fs.isDir(FilePath) then
  103. PastPaths[#PastPaths + 1] = FilePath
  104. DisplayPath()
  105. else
  106. if fs.exists(FilePath..".lua") then
  107. shell.run("edit",FilePath)
  108. else
  109. shell.run("os/System/Programs/TextEditor","direct",FilePath)
  110. end
  111. FilePath = PastPaths[#PastPaths]
  112. DisplayPath()
  113. end
  114. end
  115. end
  116.  
  117. if tArg[1] == "Show" then
  118. FilePath = tArg[2]
  119. end
  120.  
  121. DisplayPath()
Add Comment
Please, Sign In to add comment