Marlingaming

CC Tweaked CCSPS Iron - Profile Editor

Feb 3rd, 2022 (edited)
146
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.78 KB | None | 0 0
  1. local AdRegions = {"Vedrana","Goldshelm","SaltFlats"}
  2.  
  3. local function Clear()
  4. term.clear()
  5. term.setCursorPos(1,1)
  6. end
  7.  
  8. function CUI(m) --declare function
  9. n=1
  10. local l = #m
  11. while true do
  12. term.setCursorPos(1,5)
  13. for i=1, #m, 1 do --traverse the table of options
  14. if i==n then term.clearLine() print(i, ">",m[i]) else term.clearLine() print(i, "-", m[i]) end --print them
  15. end
  16. a, b= os.pullEvent("key") --wait for keypress
  17. if b==keys.w and n>1 then n=n-1 end
  18. if b==keys.s and n<l then n=n+1 end
  19. if b==keys.enter then break end
  20. end
  21. return n --return the value
  22. end
  23.  
  24. function EditItem(item,type)
  25. Clear()
  26. print("editing ",item)
  27. local file = fs.open("os/System/Client/Files/.UserFile.txt","r")
  28. local User = file.readLine()
  29. local Reg = file.readLine()
  30. local Tax = file.readLine()
  31. local Access = file.readLine()
  32. local Add = file.readLine()
  33. file.close()
  34. local Acc = fs.open("os/System/Client/Files/.UserFile.txt","w")
  35. local input
  36. if type == "text" then
  37. while true do
  38. local event = {os.pullEvent("key")}
  39. if event[2] == keys.enter then break end
  40. input = read()
  41. end
  42. elseif type == "Sel" and item == "region" then
  43. local options = AdRegions
  44. local n = CUI(options)
  45. input = options[n]
  46. end
  47. if item == "username" then
  48. User = input
  49. elseif item == "region" then
  50. Reg = input
  51. elseif item == "address" then
  52. Add = input
  53. end
  54. Acc.writeLine(User)
  55. Acc.writeLine(Reg)
  56. Acc.writeLine(Tax)
  57. Acc.writeLine(Access)
  58. Acc.writeLine(Add)
  59. Acc.close()
  60. end
  61.  
  62. function Menu()
  63. Clear()
  64. local options = {"username","region","address","exit"}
  65. local n = CUI(options)
  66. if options[n] == "exit" then
  67.  
  68. else
  69. if options[n] == "region" then
  70. EditItem(options[n],"Sel")
  71. else
  72. EditItem(options[n],"text")
  73. end
  74. Menu()
  75. end
  76. end
  77.  
  78. Menu()
Add Comment
Please, Sign In to add comment