Advertisement
Marlingaming

CC Tweaked CCSPS Iron 2.0.0 - File properties Editor

Feb 10th, 2022 (edited)
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.29 KB | None | 0 0
  1. local tArg = {...}
  2. local FilePath = tArg[1]
  3. local ShortcutType = "n"
  4. local ShortcutName = "n"
  5. local ShortcutImage = "n"
  6. local ShortcutPath = "n"
  7.  
  8. local function Clear()
  9. term.clear()
  10. term.setCursorPos(1,1)
  11. end
  12.  
  13. local function GetFile()
  14. local List = fs.list("os/System/Saved/Shortcuts")
  15. for i = 1, #List do
  16. local file = fs.open(fs.combine("os/System/Saved/Shortcuts",List[i]),"r")
  17. local A = file.readLine()
  18. local Content = file.readLine()
  19. local B = file.readLine()
  20. local C = file.readLine()
  21. file.close()
  22. if Content == FilePath then
  23. ShortcutType = C
  24. ShortcutName = A
  25. ShortcutImage = B
  26. ShortcutPath = List[i]
  27. end
  28. end
  29. end
  30.  
  31. function EditItem(item)
  32. local Pos
  33. local y = 1
  34. if item == "Type" then
  35. Pos = {"n","Popup","Desktop","Taskbar"}
  36. y = 3
  37. elseif item == "Name" then
  38. Pos = {}
  39. y = 4
  40. elseif item == "Image" then
  41. Pos = fs.list("os/System/Saved/Images")
  42. y = 5
  43. end
  44. term.setCursorPos(1,y)
  45. term.clearLine()
  46. local completion = require "cc.completion"
  47. local input
  48. while true do
  49. local event = {os.pullEvent("key")}
  50. if event[2] == keys.enter then break end
  51. input = read(nil, nil, function(text) return completion.choice(text, Pos) end)
  52. end
  53. if item == "Type" then
  54. ShortcutType = input
  55. elseif item == "Name" then
  56. ShortcutName = input
  57. elseif item == "Image" then
  58. ShortcutImage = fs.combine("os/System/Saved/Images",input)
  59. end
  60. local file = fs.open(fs.combine("os/System/Saved/Shortcuts",ShortcutPath),"w")
  61. file.writeLine(ShortcutName)
  62. file.writeLine(FilePath)
  63. file.writeLine(ShortcutImage)
  64. file.writeLine(ShortcutType)
  65. file.close()
  66. end
  67.  
  68. function Panel()
  69. GetFile()
  70. term.setBackgroundColor(colors.lightBlue)
  71. Clear()
  72. print("[x] file properties")
  73. print("[",FilePath,"]")
  74. term.setCursorPos(1,3)
  75. print("Shortcut : ",ShortcutType)
  76. term.setCursorPos(1,4)
  77. print("Name : ",ShortcutName)
  78. term.setCursorPos(1,5)
  79. print("Image : ",ShortcutName)
  80. term.setCursorPos(1,6)
  81. print("===Other===")
  82. end
  83.  
  84. function Inter()
  85. while true do
  86. local a, b, c, d = os.pullEvent("mouse_click")
  87. if c < 4 and d == 1 then break end
  88. if d == 3 then EditItem("Type") end
  89. if d == 4 then EditItem("Name") end
  90. if d == 5 then EditItem("Image") end
  91. Panel()
  92. end
  93. end
  94.  
  95. Panel()
  96. Inter()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement