Advertisement
kwstoudt

Village Railway Ticket System

Dec 30th, 2014
242
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. --Load the API
  2. os.loadAPI("touchpoint")
  3.  
  4. --Wrap the Ticket Machine
  5. p=peripheral.wrap("top")
  6.  
  7. --Establish Button Pages
  8. local page1 = touchpoint.new("right")
  9. local page2 = touchpoint.new("right")
  10. local page3 = touchpoint.new("right")
  11. local page4 = touchpoint.new("right")
  12. --one variable to put each page into in order to simplify switching
  13. local t
  14.  
  15. --Village Ticket Functions
  16. function v1()
  17.   t:flash("Village 1")
  18.   p.createTicket("Village01",1)
  19.   shell.run("shutdown")
  20. end
  21.  
  22. function v2()
  23.   t:flash("Village 2")
  24.   p.createTicket("Village02",1)
  25.   shell.run("shutdown")
  26. end
  27.  
  28. function v3()
  29.   t:flash("Village 3")
  30.   p.createTicket("Village3",1)
  31.   shell.run("shutdown")
  32. end
  33.  
  34. function v4()
  35.   t:flash("Village 4")
  36.   p.createTicket("Village4",1)
  37.   shell.run("shutdown")
  38. end
  39.  
  40. function v5()
  41.   t:flash("Village 5")
  42.   p.createTicket("Village5",1)
  43.   shell.run("shutdown")
  44. end
  45.  
  46. function v6()
  47.   t:flash("Village 6")
  48.   p.createTicket("Village6",1)
  49.   shell.run("shutdown")
  50. end
  51.  
  52. function v7()
  53.   t:flash("Village 7")
  54.   p.createTicket("Village7",1)
  55.   shell.run("shutdown")
  56. end
  57.  
  58. function v8()
  59.   t:flash("Village 8")
  60.   p.createTicket("Village8",1)
  61.   shell.run("shutdown")
  62. end
  63.  
  64. function v9()
  65.   t:flash("Village 9")
  66.   p.createTicket("Village9",1)
  67.   shell.run("shutdown")
  68. end
  69.  
  70. function v10()
  71.   t:flash("Village 10")
  72.   p.createTicket("Village10",1)
  73.   shell.run("shutdown")
  74. end
  75.  
  76. function v11()
  77.   t:flash("Village 11")
  78.   p.createTicket("Village11",1)
  79.   shell.run("shutdown")
  80. end
  81.  
  82. function v12()
  83.   t:flash("Village 12")
  84.   p.createTicket("Village12",1)
  85.   shell.run("shutdown")
  86. end
  87.  
  88. function v13()
  89.   t:flash("Village 13")
  90.   p.createTicket("Village13",1)
  91.   shell.run("shutdown")
  92. end
  93.  
  94. function v14()
  95.   t:flash("Village 14")
  96.   p.createTicket("Village14",1)
  97.   shell.run("shutdown")
  98. end
  99.  
  100. function v15()
  101.   t:flash("Village 15")
  102.   p.createTicket("Village15",1)
  103.   shell.run("shutdown")
  104. end
  105.  
  106. function v16()
  107.   t:flash("Village 16")
  108.   p.createTicket("Village16",1)
  109.   shell.run("shutdown")
  110. end
  111.  
  112. function v17()
  113.   t:flash("Village 17")
  114.   p.createTicket("Village17",1)
  115.   shell.run("shutdown")
  116. end
  117.  
  118. function v18()
  119.   t:flash("Village 18")
  120.   p.createTicket("Village18",1)
  121.   shell.run("shutdown")
  122. end
  123.  
  124. function v19()
  125.   t:flash("Village 19")
  126.   p.createTicket("Village19",1)
  127.   shell.run("shutdown")
  128. end
  129.  
  130. function v20()
  131.   t:flash("Village 20")
  132.   p.createTicket("Village20",1)
  133.   shell.run("shutdown")
  134. end
  135.  
  136. --Base Ticket Functions
  137. function b1()
  138.   t:flash("Base 1")
  139.   p.createTicket("Base1",1)
  140.   shell.run("shutdown")
  141. end
  142.  
  143. function b2()
  144.   t:flash("Base 2")
  145.   p.createTicket("Base2",1)
  146.   shell.run("shutdown")
  147. end
  148.  
  149. function b3()
  150.   t:flash("Base 3")
  151.   p.createTicket("Base3",1)
  152.   shell.run("shutdown")
  153. end
  154.  
  155. function b4()
  156.   t:flash("Kira")
  157.   p.createTicket("Kira",1)
  158.   shell.run("shutdown")
  159. end
  160.  
  161. function b5()
  162.   t: flash("Shelley")
  163.   p.createTicket("Shelley",1)
  164.   shell.run("shutdown")
  165. end
  166.  
  167. --Menu Functions
  168. function l1()
  169.   t = page1
  170. end
  171.  
  172. function l2()
  173.   t = page2
  174. end
  175.  
  176. function l3()
  177.   t = page3
  178. end
  179.  
  180. function l4()
  181.   t = page4
  182. end
  183.  
  184. --Shutdown Function
  185. function sd()
  186.   shell.run("shutdown")
  187. end
  188.  
  189. --set up pages
  190. do
  191.   page1:add("Village 1", v1, 3, 2, 16, 2, colors.red, colors.lime)
  192.   page1:add("Village 2", v2, 3, 4, 16, 4, colors.red, colors.lime)
  193.   page1:add("Village 3", v3, 3, 6, 16, 6, colors.red, colors.lime)
  194.   page1:add("Village 4", v4, 3, 8, 16, 8, colors.red, colors.lime)
  195.   page1:add("Village 5", v5, 3, 10, 16, 10, colors.red, colors.lime)
  196.   page1:add("Village 6", v6, 3, 12, 16, 12, colors.red, colors.lime)
  197.   page1:add("Village 7", v7, 3, 14, 16, 14, colors.red, colors.lime)
  198.   page1:add("Next", l2, 3, 16, 16, 16, colors.lightBlue, colors.lightBlue)
  199.   page1:add("Shutdown", sd, 3, 18, 16, 18, colors.orange, colors.orange)
  200.  
  201.   page2:add("Previous", l1, 3, 2, 16, 2, colors.lightBlue, colors.lightBlue)
  202.   page2:add("Village 8", v8, 3, 4, 16, 4, colors.red, colors.lime)
  203.   page2:add("Village 9", v9, 3, 6, 16, 6, colors.red, colors.lime)
  204.   page2:add("Village 10", v10, 3, 8, 16, 8, colors.red, colors.lime)
  205.   page2:add("Village 11", v11, 3, 10, 16, 10, colors.red, colors.lime)
  206.   page2:add("Village 12", v12, 3, 12, 16, 12, colors.red, colors.lime)
  207.   page2:add("Village 13", v13, 3, 14, 16, 14, colors.red, colors.lime)
  208.   page2:add("Next", l3, 3, 16, 16, 16, colors.lightBlue, colors.lightBlue)
  209.   page2:add("Shutdown", sd, 3, 18, 16, 18, colors.orange, colors.orange)
  210.  
  211.   page3:add("Previous", l2, 3, 2, 16, 2, colors.lightBlue, colors.lightBlue)
  212.   page3:add("Village 14", v14, 3, 4, 16, 4, colors.red, colors.lime)
  213.   page3:add("Village 15", v15, 3, 6, 16, 6, colors.red, colors.lime)
  214.   page3:add("Village 16", v16, 3, 8, 16, 8, colors.red, colors.lime)
  215.   page3:add("Village 17", v17, 3, 10, 16, 10, colors.red, colors.lime)
  216.   page3:add("Village 18", v18, 3, 12, 16, 12, colors.red, colors.lime)
  217.   page3:add("Village 19", v19, 3, 14, 16, 14, colors.red, colors.lime)
  218.   page3:add("Next", l4, 3, 16, 16, 16, colors.lightBlue, colors.lightBlue)
  219.   page3:add("Shutdown", sd, 3, 18, 16, 18, colors.orange, colors.orange)
  220.  
  221.   page4:add("Previous", l3, 3, 2, 16, 2, colors.lightBlue, colors.lightBlue)
  222.   page4:add("Village 20", v20, 3, 4, 16, 4, colors.red, colors.lime)
  223.   page4:add("Base 1", b1, 3, 6, 16, 6, colors.red, colors.lime)
  224.   page4:add("Base 2", b2, 3, 8, 16, 8, colors.red, colors.lime)
  225.   page4:add("Base 3", b3, 3, 10, 16, 10, colors.red, colors.lime)
  226.   page4:add("Kira", b4, 3, 12, 16, 12, colors.red, colors.lime)
  227.   page4:add("Shelley", b5, 3, 14, 16, 14, colors.red, colors.lime)
  228.   page4:add("Shutdown", sd, 3, 18, 16, 18, colors.orange, colors.orange)
  229.  
  230. end
  231.  
  232. --Starts with Page 1, then checks for buttons clicked, toggles them, and runs the program it has with my modified t:run2()
  233. l1()
  234. while true do
  235.   t:draw()
  236.   -- local event, p1, p2, p3 = os.pullEvent() ---monitor_touch, side, xpos, ypos
  237.   local event, p1 = t:handleEvents(os.pullEvent()) ---button_click, name
  238.   if event == "button_click" then
  239.     --remove toggling and simplify button running
  240.     t.buttonList[p1].func()
  241.   end
  242. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement