Marlingaming

CC Tweaked Train Station Ticket Kiosk

Jan 18th, 2022 (edited)
240
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.42 KB | None | 0 0
  1. --this script allows the purchase and reactivation of National Train Line Credit Cards, which are used for payment of tickets and allows entrence innmost Train stations
  2. local w, h = term.getSize()
  3. local Credit = 0
  4. local User = "guest"
  5.  
  6. local AvailableLines = {"Northern Outpost"}
  7.  
  8. local function Clear()
  9. term.clear()
  10. term.setCursorPos(1,1)
  11. end
  12.  
  13. function CUI(m) --declare function
  14. n=1
  15. local l = #m
  16. while true do
  17. term.setCursorPos(1,5)
  18.  
  19. for i=1, #m, 1 do --traverse the table of options
  20. if i==n then term.clearLine() print(i, " ["..m[i].."]") else term.clearLine() print(i, " ", m[i]) end --print them
  21. end
  22. a, b= os.pullEvent("key") --wait for keypress
  23. if b==keys.w and n>1 then n=n-1 end
  24. if b==keys.s and n<l then n=n+1 end
  25. if b==keys.enter then break end
  26. end
  27. return n --return the value
  28. end
  29.  
  30. local function PageDraw(page)
  31. if page == "Login" then
  32.     term.setBackgroundColor(colors.cyan)
  33.     Clear()
  34.     print("Central Rail Network Kiosk")
  35.     print("Please Login")
  36.     term.write("Code = ")
  37. elseif page == "Menu" then
  38.     term.setBackgroundColor(colors.green)
  39.     Clear()
  40.     print("Central Rail Network Kiosk")
  41.     print("Hello, "..User)
  42. elseif page == "Swipe" then
  43.    
  44. elseif page == "Lines" then
  45.     term.setBackgroundColor(colors.black)
  46.     Clear()
  47.     print("Central Rail Network Kiosk")
  48. elseif page == "Line Details" then
  49.        
  50. end
  51. end
  52.  
  53. local function AccountPage()
  54.  
  55. end
  56.  
  57. local function LinesPage()
  58.  
  59. end
  60.  
  61. local function LineDetails(LineName)
  62.  
  63. end
  64.  
  65. local function TicketsPage()
  66. local Options = AvailableLines
  67. Options[#Options +1] = "exit"
  68. local n = CUI(Options)
  69. if Options[n] == "exit" then
  70.     MainMenu()
  71. else
  72.     LineDetails(Options[n])
  73. end
  74. end
  75.  
  76. local function MainMenu()
  77. PageDraw("Menu")
  78. local Options = {"Account","Lines","Buy Ticket","Logout"}
  79. local n = CUI(Options)
  80. if Options[n] == "Account" then
  81.     AccountPage()
  82. elseif Options[n] == "Lines" then
  83.     LinesPage()
  84. elseif Options[n] == "Buy Ticket" then
  85.     TicketsPage()
  86. elseif Options[n] == "Logout" then
  87.     Logout()
  88. end
  89. end
  90.  
  91. local function Login()
  92. PageDraw("Login")
  93. local input
  94. while true do
  95.     input = read
  96.     if string.len(input) == 6 then
  97.         break
  98.     end
  99. end
  100. local file = fs.open("Users","r")
  101. local Contents = file.readAll()
  102. if Contents.find(input) == true then
  103.     User = input
  104.     MainMenu()
  105. else
  106.     Login()
  107. end
  108. end
  109.  
  110. local function Logout()
  111. User = "guest"
  112. PageDraw("Login")
  113. end
Add Comment
Please, Sign In to add comment