Advertisement
Marlingaming

Gov forum writer cc tweaked

Dec 10th, 2023
49
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.43 KB | None | 0 0
  1. local Page = "Home"
  2.  
  3. function Input(y)
  4. local n = 1
  5. local Text
  6. while true do
  7. term.setCursorPos(1,y)
  8. term.clearLine()
  9. if n == 1 then if Text ~= nil then term.write("> ["..Text.."]") else term.write("> [_]") end else if Text ~= nil then term.write("["..Text.."]") else term.write("[_]") end end
  10. term.setCursorPos(1,y+1)
  11. term.clearLine()
  12. if n == 2 then term.write("> -enter") else term.write("-enter") end
  13. term.setCursorPos(1,y+2)
  14. term.clearLine()
  15. term.write("use arrow keys")
  16. local event, a, b = os.pullEvent()
  17. if event == "key" and a ~= 265 and a ~= 264 and n == 1 then term.setCursorPos(1,y) term.clearLine() Text = read() end
  18. if event == "key" and (a == 265 or a == 264) then if n == 1 then n = 2 else n = 1 end end
  19. if n == 2 and a == keys.enter then break end
  20. end
  21. term.clear()
  22. return Text
  23. end
  24.  
  25. function List(y,options)
  26. local n = 1
  27. while true do
  28. for i = 1, #options do
  29. term.setCursorPos(1,(i-1)+y)
  30. term.clearLine()
  31. if n == i then term.write("> -"..options[i]) else term.write("-"..options[i]) end
  32. end
  33. term.setCursorPos(1,y+#options)
  34. term.clearLine()
  35. term.write("W/S, Enter")
  36. local a, b, c = os.pullEvent("key")
  37. if b == keys.w or b == 265 then if n == 1 then n = #options else n = n - 1 end end
  38. if b == keys.s or b == 264 then if n == #options then n = 1 else n = n + 1 end end
  39. if b == keys.enter then break end
  40. end
  41. term.clear()
  42. return n
  43. end
  44.  
  45. function CreateCopyEdit(file)
  46. local Data
  47. local file = fs.open(file,"r")
  48. Data = file.readAll()
  49. file.close()
  50. file = fs.open("copy","w")
  51. file.write(Data)
  52. file.close()
  53. shell.run("edit","copy")
  54. local printer = peripheral.wrap("left")
  55. file = fs.open("copy","r")
  56. Data = file.readAll()
  57. printer.write(Data)
  58. printer.endPage()
  59. end
  60.  
  61. function UI()
  62. term.clear()
  63. term.setCursorPos(1,1)
  64. if Page == "Home" then
  65. print("Home")
  66. local n = List(3,{"tax forum","land registry","company forums"})
  67. if n == 1 then Page = "Tax Forums" elseif n == 2 then Page = "Land Registry" elseif n == 3 then Page = "Company Forums" end
  68. elseif Page == "Tax Forums" then
  69. local n = List(3,{"return"})
  70. if n == 1 then Page = "Home" end
  71. elseif Page == "Land Registry" then
  72. local n = List(3,{"register land forum","return"})
  73. if n == 1 then Page = "Home" CreateCopyEdit("landforum.txt") elseif n == 2 then Page = "Home" end
  74. elseif Page == "Company Forums" then
  75. print("Company Forums")
  76. local n = List(3,{"return"})
  77. if n == 1 then Page = "Home" end
  78. end
  79. end
  80.  
  81. function Main()
  82. while true do
  83. UI()
  84. end
  85. end
  86.  
  87. Main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement