Marlingaming

CC Tweaked CCSPS 20 - File Navigator Program

Mar 2nd, 2022 (edited)
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.90 KB | None | 0 0
  1. local tArg = {...}
  2. local FilePath = "os/SystemFiles"
  3.  
  4. function openWindow()
  5. os.queueEvent("newWindow","FileNavigator",1,1,20,20,"FInav")
  6. end
  7.  
  8. function LoadPaths()
  9. local List = fs.list(FilePath)
  10. os.queueEvent("windowButton","FileNavigator",fs.getDir(FilePath),"FInav",1,2)
  11. for i = 1, #List do
  12. os.queueEvent("windowButton","FileNavigator",fs.combine(FilePath,List[i]),"FInav",1,i + 2)
  13. end
  14. end
  15.  
  16. function WindowManager()
  17. os.queueEvent("clearWindow","FileNavigator")
  18. os.queueEvent("windowText","FileNavigator",FilePath,1,1)
  19. LoadPaths()
  20. end
  21.  
  22. function ViewText(file)
  23. os.queueEvent("newWindow",file,1,1,20,20,"FInav")
  24. local FI = fs.open(file,"r")
  25. local Content
  26. local i = 1
  27. repeat
  28. Content = FI.readLine()
  29. if Content ~= nil then os.queueEvent("windowText",file,Content,1,i+ 1) end
  30. i = i + 1
  31. until Content == nil
  32. FI.close()
  33. end
  34.  
  35. function ViewImage(file)
  36. os.queueEvent("newWindow",file,1,1,20,20,"FInav")
  37. os.queueEvent("windowImage",file,file,1,1)
  38. end
  39.  
  40. function OpenProgram(file)
  41. local List = fs.list(file)
  42. local Loc
  43. local File
  44. for i = 1, #List do
  45. if string.find(List[n],"AppData.txt") then Loc = fs.combine(file,List[n]) end
  46. end
  47. if Loc == nil then
  48.  
  49. else
  50. local F = fs.open(Loc,"r")
  51. local Content
  52. repeat
  53. Content = F.readLine()
  54. if string.find(Content,"StartFile = ") then File = string.sub(Content, 13, string.len(Content)) end
  55. until Content == nil
  56. if File ~= nil then shell.run(File,"start") end
  57. end
  58. end
  59.  
  60. if tArg[1] == "start" then
  61. openWindow()
  62. WindowManager()
  63. end
  64.  
  65. if tArg[1] ~= nil and tArg[1] ~= "start" then
  66. if fs.isDir(tArg[1]) == true then
  67. FilePath = tArg[1]
  68. elseif string.find(tArg[1],".txt") then
  69. ViewText(tArg[1])
  70. elseif string.find(tArg[1],".cpf") then
  71. OpenProgram(tArg[1])
  72. elseif string.find(tArg[1],".nfp") then
  73. ViewImage(tArg[1])
  74. end
  75. WindowManager()
  76. end
Add Comment
Please, Sign In to add comment