Advertisement
mr_arte

fahrkarte.lua

May 12th, 2022
626
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. -- ##### Variablen
  2. printer = peripheral.find("printer")
  3. flop = peripheral.find("disk")
  4. mon = peripheral.find("monitor")
  5.  
  6.  
  7.   --Boxen
  8.   xbox = 2
  9.   ybox = 2
  10.   xbox_re = xbox + 24
  11.   ybox_m = ybox + 6
  12.   ybox_u = ybox + 12
  13.   xadd = 22
  14.   yadd = 4
  15.  
  16. -- ##### Vorprozeduren
  17. term.clear()
  18.  
  19. printer.getPaperLevel()
  20. printer.getInkLevel()
  21.  
  22. term.setCursorPos(11,4)
  23. term.write("Mine")
  24.  
  25. term.setCursorPos(32,10)
  26. term.write("Strecke 4")
  27.  
  28. term.setCursorPos(7,10)
  29. term.write("Bootsverleih")
  30.  
  31. term.setCursorPos(23,4)
  32. term.write("Strecke 3")
  33.  
  34. -- Boxen malen
  35.  
  36. paintutils.drawBox(xbox, ybox, xbox + xadd, ybox + yadd, colors.red)
  37. paintutils.drawBox(xbox, ybox_m, xbox + xadd, ybox_m + yadd, colors.blue)
  38. paintutils.drawBox(xbox_re, ybox_m, xbox_re + xadd, ybox_m + yadd, colors.green)
  39. paintutils.drawBox(xbox_re, ybox, xbox_re + xadd, ybox + yadd, colors.yellow)
  40. paintutils.drawBox(xbox, ybox_u, xbox + xadd, ybox_u + yadd, colors.purple)
  41. paintutils.drawBox(xbox_re, yboy_u, xbox_re + xadd, ybox_u + yadd, colors.brown)
  42.  
  43. -- ##### Funktionen
  44. function flopcop()
  45.     if disk.isPresent("right") then
  46.         disk.setLabel("right", "Fahrschein")
  47.         fs.copy(prog, progdest)
  48.         sleep(0.5)
  49.         disk.eject("right")
  50.     end
  51. end
  52.  
  53. function printit()
  54.     printer.newPage()
  55.     printer.setPageTitle("Quittung")
  56.    
  57.     printer.setCursorPos(1,1)
  58.     printer.write("........................")
  59.    
  60.     printer.setCursorPos(2,3)
  61.     printer.write("Strecke:")
  62.     printer.setCursorPos(15,3)
  63.     printer.write(destination1)
  64.  
  65.     printer.setCursorPos(2,4)
  66.     printer.write("Haltestelle:")
  67.     printer.setCursorPos(15,4)
  68.     printer.write(destination2)
  69.  
  70.     printer.setCursorPos(1,6)
  71.     printer.write("........................")
  72.  
  73.     printer.setCursorPos(3,9)
  74.     printer.write("Preis:")
  75.     printer.setCursorPos(16,9)
  76.     printer.write(preis)
  77.  
  78.     printer.setCursorPos(3,11)
  79.     printer.write("Umstiege:")
  80.     printer.setCursorPos(16,11)
  81.     printer.write(umstiege)
  82.  
  83.     printer.setCursorPos(3,13)
  84.     printer.write("Wartezeiten:")
  85.     printer.setCursorPos(16,13)
  86.     printer.write(warten)
  87.  
  88.     printer.setCursorPos(1,18)
  89.     printer.write("........................")
  90.     printer.setCursorPos(1,19)
  91.     printer.write("Bitte entnehmen Sie Ihren")
  92.     printer.setCursorPos(1,20)
  93.     printer.write("Fahrschein")
  94.  
  95.     printer.endPage()
  96. end
  97.  
  98. -- ##### Hauptprogramm
  99.  mon.clear()
  100.  mon.setCursorPos(7,1)
  101.  mon.write("Fahrkartenautomat")
  102.  mon.setCursorPos(1,2)
  103.  mon.write("----------------------")
  104.  mon.setCursorPos(4,4)
  105.  mon.write("Hier Fahrschein kaufen")
  106.  
  107. while true do
  108.     local event, button, x, y = os.pullEvent()
  109.     if event == "mouse_click" then
  110.         if x >= xbox and y >= ybox and x <= xbox + xadd and y <= ybox + yadd then
  111.             x = "1"
  112.  
  113.             prog = "dest_mine.lua"
  114.             progdest = "disk/dest_mine.lua"
  115.             flopcop()
  116.  
  117.             destination1 = "1: Mine"
  118.             destination2 = "Basecamp II"
  119.             preis = "2,50 EUR"
  120.             umstiege = "0"
  121.             warten = "Möglich"
  122.             printit()
  123.  
  124.         elseif x >= xbox and y >= ybox_m and x <= xbox + xadd and y <= ybox_m + yadd then
  125.             x = "1"
  126.  
  127.             prog = "dest_2"
  128.             progdest = "disk/dest_2"
  129.             flopcop()
  130.  
  131.             destination1 = "2: BVL"
  132.             destination2 = "Bootsverl."
  133.             preis = "0,50 EUR"
  134.             umstiege = "0"
  135.             warten = "NEIN"
  136.             printit()
  137.         elseif x >= xbox_re and y >= ybox and x <= xbox_re + xadd and y <= ybox + yadd then
  138.             x = "1"
  139.  
  140.             prog = "dest_3"
  141.             progdest = "disk/dest_3"
  142.             flopcop()
  143.  
  144.             destination1 = "3: Strecke"
  145.             destination2 = "Halte"
  146.             preis = "3,50 EUR"
  147.             umstiege = "0"
  148.             warten = "NEIN"
  149.             printit()
  150.         elseif x >= xbox_re and y >= ybox and x <= xbox_re + xadd and y <= ybox + yadd then
  151.             x = "1"
  152.  
  153.             prog = "dest_4"
  154.             progdest = "disk/dest_4"
  155.             flopcop()
  156.  
  157.             destination1 = "4: Strecke"
  158.             destination2 = "Halte"
  159.             preis = "5,- EUR"
  160.             umstiege = "0"
  161.             warten = "NEIN"
  162.             printit()
  163.         elseif x >=xbox and y >= ybox_u and x <= xbox + xadd and y <= ybox_u + yadd then
  164.             x = "1"
  165.  
  166.             prog = "dest_5"
  167.             progdest = "disk/dest_5"
  168.             flopcop()
  169.  
  170.             destination1 = "5: Strecke"
  171.             destination2 = "Halte"
  172.             preis = "8,- EUR"
  173.             umstiege = "0"
  174.             warten = "NEIN"
  175.             printit()
  176.         elseif x >= xbox_re and y >= yboy_u and x <= xbox_re + xadd and y <= ybox_u + yadd then
  177.             x = "1"
  178.  
  179.             prog = "dest_6"
  180.             progdest = "disk/dest_6"
  181.             flopcop()
  182.  
  183.             destination1 = "6: Strecke"
  184.             destination2 = "Halte"
  185.             preis = "9,50- EUR"
  186.             umstiege = "0"
  187.             warten = "NEIN"
  188.             printit()
  189.         end
  190.     end
  191. end
Advertisement
RAW Paste Data Copied
Advertisement