Advertisement
Marlingaming

CC Tweaked User Document Writer

Jan 19th, 2022 (edited)
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.51 KB | None | 0 0
  1. --this script is used to print out ID Papers
  2. local SecurityCode = "3gd2y32"
  3. local Details
  4.  
  5. local function Clear()
  6. term.clear()
  7. term.setCursorPos(1,1)
  8. end
  9.  
  10. local function EditItem(item)
  11. local I = 1
  12. if item == "Name" then
  13. I = 1
  14. elseif item == "Address" then
  15. I = 2
  16. elseif item == "SecurityNumber" then
  17. I = 3
  18. elseif item == "Settlement" then
  19. I = 4
  20. elseif item == "Clearance" then
  21. I = 5
  22. end
  23. Clear()
  24. print(item)
  25. print("type answer, then press enter twice to save")
  26. print("Last Input = "..Details[I])
  27. local input
  28. local event, key
  29. repeat
  30. event, key = os.pullEvent("key")
  31. input = read()
  32. until key == keys.enter
  33. Details[I] = input
  34. DocDrawer()
  35. end
  36.  
  37. function CUI(m) --declare function
  38. n=1
  39. local l = #m
  40. while true do
  41. CenterText(TimeSpot, os.date())
  42. term.setCursorPos(1,5)
  43.  
  44. for i=1, #m, 1 do --traverse the table of options
  45. if i==n then term.clearLine() print(i, " ["..m[i].."]") else term.clearLine() print(i, " ", m[i]) end --print them
  46. end
  47. if b==keys.w and n>1 then n=n-1 end
  48. if b==keys.s and n<l then n=n+1 end
  49. if b==keys.enter then break end
  50. CenterText(TimeSpot, os.date())
  51. end
  52. return n --return the value
  53. end
  54.  
  55. local function CleanDoc()
  56. Details = {"none","n","00000","spawn","0"}
  57. end
  58.  
  59. local function PrintDoc()
  60. Clear()
  61. print("print Doc....")
  62. local printer = peripherals.find("printer")
  63. local Path = (Details[1].."_"..os.date())
  64. local file = fs.open(Path,"a")
  65. file.writeLine("--===ID===--")
  66. file.writeLine("Name: "..Details[1])
  67. file.writeLine("Clearance: "..Details[5])
  68. file.writeLine("Address : "..Details[2])
  69. file.writeLine("Settlement : "..Details[4])
  70. file.writeLine("Security Number : "..Details[3])
  71. file.writeLine("Printed on : "..os.date())
  72. file.writeLine("On Computer : "..os.computerID())
  73. file.writeLine(SecurityCode)
  74. printer.newPage()
  75. printer.setPageTitle(Details[1].." Identification")
  76. printer.write(file.readAll()
  77. printer.endPage()
  78. file.close()
  79. CleanDoc()
  80. Clear()
  81. DocDrawer()
  82. end
  83.  
  84. local function DocDrawer()
  85. Clear()
  86. print("====Identification=Document====")
  87. local options = {"Name","Address","SecurityNumber","Settlement","Clearance","==print=="}
  88. local n = CUI(options)
  89. if options[n] == "Name" then
  90. EditItem("Name")
  91. elseif options[n] == "Address" then
  92. EditItem("Address")
  93. elseif options[n] == "SecurityNumber" then
  94. EditItem("SecurityNumber")
  95. elseif options[n] == "Settlement" then
  96. EditItem("Settlement")
  97. elseif options[n] == "Clearance" then
  98. EditItem("Clearance")
  99. elseif options[n] == "==print==" then
  100. PrintDoc()
  101. end
  102. end
  103.  
  104. CleanDoc()
  105. Clear()
  106. DocDrawer()
  107.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement