MagmaLP

Mall_Tausch_PC

Dec 29th, 2021 (edited)
810
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 11.25 KB | None | 0 0
  1. term.setBackgroundColor(32768)
  2. term.clear()
  3. rs.setOutput("top", true)
  4. sleep(0.5)
  5.  
  6.  
  7. function calc_color(color)
  8.     return math.pow(2, color - 1)
  9. end
  10.  
  11. function msg(gap, line, color, groundb, text)
  12.     term.setBackgroundColor(calc_color(groundb))
  13.     term.setCursorPos(gap,line)
  14.     term.setTextColor(calc_color(color))
  15.     text = term.write(text)
  16. end  
  17.  
  18. function neueracc()
  19.     term.setBackgroundColor(32768)
  20.     term.clear()
  21.     msg(14,02,04,16,"Neuen Account erstellen")
  22.  
  23.     msg(02,05,04,16,"Wie soll dein Name sein?")
  24.     msg(01,06,04,16,"---------------------------------------------------")
  25.     msg(02,07,06,16,"")
  26.     local name = read()
  27.     if fs.exists("benutzer/" ..name) == true then      
  28.         msg(02,07,15,16,"Dieser Name ist schon vergeben")
  29.         sleep(1)
  30.         neueracc()
  31.     end
  32.  
  33.     msg(02,10,04,16,"Wie soll dein Passwort sein?")
  34.     msg(01,11,04,16,"---------------------------------------------------")
  35.     msg(02,12,06,16,"")
  36.     local passwort1 = read("*")
  37.  
  38.     msg(02,15,04,16,"Bitte Passwort wiederholen!")
  39.     msg(01,16,04,16,"---------------------------------------------------")
  40.     msg(02,17,06,16,"")
  41.     local passwort2 = read("*")
  42.     if passwort1 ~= passwort2 then
  43.         msg(02,17,15,16,"Das Passwort ist nicht gleich!")
  44.         sleep(1)
  45.         neueracc()
  46.     else
  47.         local file = fs.open("benutzer/" ..name.. "/", "w")
  48.         file.write(passwort1)
  49.         file.close()
  50.         local file = fs.open("geld/" ..name.. "/", "w")
  51.         file.write(0.0)
  52.         file.close()
  53.     end
  54.     msg(02,17,06,16,"Account wird erstellt.")
  55.     sleep(1)
  56.     start()
  57. end
  58.  
  59. function anmelden()
  60.     term.setBackgroundColor(32768)
  61.     term.clear()
  62.     msg(14,02,04,16,"Mit Account anmelden")
  63.  
  64.     msg(02,05,04,16,"Wie lautet dein Name?")
  65.     msg(01,06,04,16,"---------------------------------------------------")
  66.     msg(02,07,06,16,"")
  67.     name = read()  
  68.     if fs.exists("benutzer/" ..name) == false then
  69.         msg(02,07,06,16,"Benutzername existiern nicht")
  70.         sleep(1)
  71.         start()
  72.     end
  73.  
  74.     msg(02,10,04,16,"Wie lautet dein Passwort?")
  75.     msg(01,11,04,16,"---------------------------------------------------")
  76.     msg(02,12,06,16,"")
  77.     local passwort = read("*")
  78.     file = fs.open("benutzer/" ..name, "r")
  79.     local inhalt = file.readLine()
  80.     file.close()
  81.    
  82.     if passwort ~= inhalt then
  83.         msg(02,12,06,16,"Passwort falsch")
  84.         sleep(1)
  85.         start()
  86.     else
  87.         hauptbildschirm()
  88.     end              
  89. end
  90.  
  91. function hauptbildschirm()
  92.     term.setBackgroundColor(32768)
  93.     term.setCursorPos(1,1)
  94.     term.clear()
  95.    
  96.  
  97.     file = fs.open("geld/" ..name, "r")
  98.     local dollar = file.readLine()
  99.     file.close()
  100.  
  101.     msg(01,01,06,16,"< Account von "..name.." >")   msg(36,01,06,16," >  "..dollar.."$        ")
  102.     msg(01,02,04,16,"---------------------------------------------------")
  103.  
  104.     msg(06,07,15,15,"                  ")   msg(29,07,15,15,"                  ")
  105.     msg(06,08,15,15,"                  ")   msg(29,08,15,15,"                  ")
  106.     msg(06,09,15,15,"                  ")   msg(29,09,15,15,"                  ")
  107.  
  108.     msg(16,14,15,15,"                     ")
  109.     msg(16,15,15,15,"                     ")
  110.     msg(16,16,15,15,"                     ")
  111.  
  112.     msg(08,08,01,15,"Geld einzahlen")
  113.     msg(31,08,01,15,"Geld auszahlen")
  114.     msg(20,15,01,15,"Items kaufen")
  115.  
  116.     local event, button, X, Y = os.pullEvent("mouse_click")
  117.     if X >= 06 and X <= 23 and Y >= 07 and Y <= 09 then
  118.         einzahlen()
  119.     elseif X >= 29 and X <= 46 and Y >= 07 and Y <= 09 then
  120.         setnull()
  121.     elseif X >= 16 and X <= 36 and Y >= 14 and Y <= 16 then
  122.         kaufen1()
  123.     else
  124.         hauptbildschirm()
  125.     end
  126. end
  127.    
  128. function einzahlen()
  129.     term.setBackgroundColor(32768)
  130.     term.clear()
  131.     file = fs.open("geld/" ..name, "r")
  132.     local dollar = file.readLine()
  133.     file.close()
  134.  
  135.     msg(01,01,06,16,"< Account von "..name.." >")   msg(36,01,06,16," >  "..dollar.."$        ")
  136.     msg(01,02,04,16,"---------------------------------------------------")
  137.     msg(01,05,04,16,"Bitte jetzt Tungston Ore links einwerfen.")
  138.     msg(01,06,04,16,"1x Tungston Ore = 42$")
  139.  
  140.     msg(01,08,04,16,"Danach hier bestätigen:")
  141.     msg(01,09,04,16,"Bitte erst bestätigen, wenn das Tungston Ore auf")
  142.     msg(01,10,04,16,"dem Monitor angezeigt wird, Sonst evlt Itemverlust.")
  143.  
  144.     msg(01,11,04,16,"---------------------------------------------------")
  145.     msg(06,13,15,15,"                  ")   msg(29,13,15,15,"                  ")
  146.     msg(06,14,01,15,"    Einzahlen     ")   msg(29,14,01,15,"    Abbrechen     ")
  147.     msg(06,15,15,15,"                  ")   msg(29,15,15,15,"                  ")
  148.     rs.setOutput("top", false)
  149.     sleep(0.5)
  150.  
  151.     local event, button, X, Y = os.pullEvent("mouse_click")
  152.     if X >= 29 and X <= 46 and Y >= 13 and Y <= 15 then
  153.         rs.setOutput("top", true)
  154.         hauptbildschirm()
  155.     elseif X >= 06 and X <= 23 and Y >= 13 and Y <= 15 then
  156.         msg(01,17,06,16,"Einzahlung läuft, bitte warten.")
  157.  
  158.         y = 1
  159.         rednet.open("bottom")
  160.         rednet.send(7955,y)
  161.         x, dollar2, z = rednet.receive()   
  162.         dollar = dollar + dollar2
  163.         local file = fs.open("geld/" ..name.. "/", "w")
  164.         file.write(dollar)
  165.         file.close()
  166.         rs.setOutput("top", true)
  167.         hauptbildschirm()      
  168.     else
  169.         einzahlen()
  170.     end
  171. end
  172.  
  173. function setnull()
  174.     auszahlmenge = 0.0
  175.     auszahlbetrag = 0.0
  176.     auszahlen()
  177. end
  178.  
  179. function auszahlen()
  180.     term.setBackgroundColor(32768)
  181.     term.clear()
  182.     file = fs.open("geld/" ..name, "r")
  183.     local dollar = file.readLine()
  184.     file.close()
  185.     dollar = tonumber(dollar)
  186.  
  187.     msg(01,01,06,16,"< Account von "..name.." >")   msg(36,01,06,16," >  "..dollar.."$        ")
  188.     msg(01,02,04,16,"---------------------------------------------------")
  189.  
  190.     msg(01,03,04,16,"Die Auszahlung findet in Tungston Ore statt.")
  191.     msg(01,04,04,16,"50$ = 1 Tungston Ore")
  192.     msg(01,05,04,16,"---------------------------------------------------")
  193.     msg(09,06,15,15,"       ")  msg(23,06,15,15,"       ")  msg(38,06,15,15,"       ")
  194.     msg(09,07,01,15,"  + 1  ")  msg(23,07,01,15,"  +10  ")  msg(38,07,01,15,"  +64  ")
  195.     msg(09,08,15,15,"       ")  msg(23,08,15,15,"       ")  msg(38,08,15,15,"       ")
  196.  
  197.     msg(09,10,15,15,"       ")  msg(23,10,15,15,"       ")  msg(38,10,15,15,"       ")
  198.     msg(09,11,01,15,"  - 1  ")  msg(23,11,01,15,"  -10  ")  msg(38,11,01,15,"  -64  ")
  199.     msg(09,12,15,15,"       ")  msg(23,12,15,15,"       ")  msg(38,12,15,15,"       ")
  200.  
  201.     msg(01,14,04,16,"Tungston Ore:")    msg(14,14,06,16," "..auszahlmenge.." ")
  202.     msg(23,14,04,16,"Abzug in Dollar:") msg(39,14,06,16," "..auszahlbetrag.." ")
  203.  
  204.     msg(06,16,15,15,"             ")    msg(23,16,15,15,"              ")
  205.     msg(06,17,01,15,"  Auszahlen  ")    msg(23,17,01,15,"  Abbrechen   ")
  206.     msg(06,18,15,15,"             ")    msg(23,18,15,15,"              ")
  207.  
  208.     local event, button, X, Y = os.pullEvent("mouse_click")
  209.     if X >= 09 and X <= 15 and Y >= 06 and Y <= 08 then
  210.         auszahlmenge = auszahlmenge + 1
  211.         auszahlbetrag = auszahlbetrag + 50
  212.         auszahlen()
  213.     elseif X >= 23 and X <= 29 and Y >= 06 and Y <= 08 then
  214.         auszahlmenge = auszahlmenge + 10
  215.         auszahlbetrag = auszahlbetrag + 500
  216.         auszahlen()
  217.     elseif X >= 38 and X <= 44 and Y >= 06 and Y <= 08 then
  218.         auszahlmenge = auszahlmenge + 64
  219.         auszahlbetrag = auszahlbetrag + 3200
  220.         auszahlen()
  221.  
  222.     elseif X >= 09 and X <= 15 and Y >= 10 and Y <= 12 and auszahlmenge > 0  then
  223.         auszahlmenge = auszahlmenge - 1
  224.         auszahlbetrag = auszahlbetrag - 50
  225.         auszahlen()
  226.     elseif X >= 23 and X <= 29 and Y >= 10 and Y <= 12 and auszahlmenge >= 10  then
  227.         auszahlmenge = auszahlmenge - 10
  228.         auszahlbetrag = auszahlbetrag - 500
  229.         auszahlen()
  230.     elseif X >= 38 and X <= 44 and Y >= 10 and Y <= 12 and auszahlmenge >= 64  then
  231.         auszahlmenge = auszahlmenge - 64
  232.         auszahlbetrag = auszahlbetrag - 3200
  233.         auszahlen()
  234.  
  235.     elseif X >= 06 and X <= 18 and Y >= 16 and Y <= 18 then
  236.         if auszahlbetrag <= dollar then
  237.             dollar = dollar - auszahlbetrag
  238.             local file = fs.open("geld/" ..name.. "/", "w")
  239.             file.write(dollar)
  240.             file.close()
  241.             rednet.open("bottom")
  242.             rednet.send(7957,auszahlmenge)
  243.             rs.setOutput("top", true)
  244.             hauptbildschirm()
  245.         else
  246.             msg(01,19,06,16,"Du hast zu wenig Geld")   
  247.             sleep(1)
  248.             auszahlen()
  249.         end
  250.     elseif X >= 23 and X <= 36 and Y >= 16 and Y <= 18 then
  251.             rs.setOutput("top", true)
  252.             hauptbildschirm()      
  253.     else
  254.         auszahlen()
  255.     end
  256. end
  257.  
  258.  
  259.  
  260.     local m3 = 0
  261.     local m4 = 0
  262.     local m5 = 0
  263.     local m6 = 0
  264.     local m7 = 0
  265.     local m8 = 0
  266.     local m9 = 0
  267.     local m10 = 0
  268.     local m11 = 0
  269.     local m12 = 0
  270.     local m13 = 0
  271.     local m14 = 0
  272.     local m15 = 0
  273.     local m16 = 0
  274.     local m17 = 0
  275.  
  276.  
  277.    
  278.  
  279.  
  280. function kaufen1()
  281.     term.setBackgroundColor(32768)
  282.     term.clear()
  283.     file = fs.open("geld/" ..name, "r")
  284.     local dollar = file.readLine()
  285.     file.close()
  286.  
  287.     msg(01,01,06,16,"< Account von "..name.." >")   msg(36,01,06,16," >  "..dollar.."$        ")
  288.     msg(01,02,04,16,"---------------------------------------------------")
  289.     msg(01,03,04,16,"| HV Solar Panel")                 msg(51,03,04,16,"|")
  290.     msg(01,04,04,16,"| MV Solar Panel")                 msg(51,04,04,16,"|")
  291.     msg(01,05,04,16,"| LV Solar Panel")                 msg(51,05,04,16,"|")
  292.     msg(01,06,04,16,"- ME Controller")                  msg(51,06,04,16,"-")
  293.     msg(01,07,04,16,"| ME Drive")                       msg(51,07,04,16,"|")
  294.     msg(01,08,04,16,"| ME Access Terminal")             msg(51,08,04,16,"|")
  295.     msg(01,09,04,16,"| ME Crafting Terminal")           msg(51,09,04,16,"|")
  296.     msg(01,10,04,16,"- ME Cable")                       msg(51,10,04,16,"-")
  297.     msg(01,11,04,16,"| ME Export Bus")                  msg(51,11,04,16,"|")
  298.     msg(01,12,04,16,"| ME Import Bus")                  msg(51,12,04,16,"|")
  299.     msg(01,13,04,16,"| ME Storage Bus")                 msg(51,13,04,16,"|")
  300.     msg(01,14,04,16,"- Energy Tesseract")               msg(51,14,04,16,"-")
  301.     msg(01,15,04,16,"| Quarry")                         msg(51,15,04,16,"|")
  302.     msg(01,16,04,16,"| Overclocker Upgrade")            msg(51,16,04,16,"|")
  303.     msg(01,17,04,16,"| Glass Fibre Cable")              msg(51,17,04,16,"|")
  304.     msg(01,18,04,16,"---------------------------------------------------")
  305.     msg(01,19,01,15," Kaufen ") msg(11,19,01,15," Abbrechen ")  msg(24,19,04,16,"Betrag:")
  306.     msg(44,19,01,15," Logout ")
  307.  
  308.     for i = 3,17 do
  309.         msg(40,i,01,15," + ")  
  310.     end
  311.     for i = 3,17 do
  312.         msg(44,i,04,16,"  ")
  313.     end
  314.     for i = 3,17 do
  315.         msg(47,i,01,15," - ")
  316.     end
  317.     kaufen2()
  318. end
  319.  
  320. function kaufen2()
  321.  
  322.     local event, button, X, Y = os.pullEvent("mouse_click")
  323.     for i = 3,17 do
  324.         if X >= 40 and X <= 42 and Y == i then
  325.             m3 = m3 + 1
  326.             msg(44,i,04,16,""..m1.."")
  327.             break
  328.         end
  329.         if X >= 47 and X <= 49 and Y == i then
  330.             m1 = m1 - 1
  331.             msg(44,i,04,16,""..m1.."")
  332.             break
  333.         end
  334.     end
  335.     kaufen2()
  336.  
  337.  
  338.  
  339.  
  340.    
  341.  
  342.  
  343.  
  344. end
  345.  
  346.  
  347.  
  348.  
  349.  
  350.  
  351.  
  352.  
  353.  
  354.  
  355.  
  356.  
  357.  
  358. function start()
  359.     term.setBackgroundColor(32768)
  360.     term.clear()
  361.     msg(14,03,04,16,"Neuen Account erstellen")
  362.     msg(01,04,04,16,"---------------------------------------------------")
  363.     msg(15,05,15,15,"                     ")
  364.     msg(15,06,15,15,"                     ") msg(20,06,01,15,"klick hier") 
  365.     msg(15,07,15,15,"                     ")
  366.     msg(01,08,04,16,"---------------------------------------------------")
  367.  
  368.     msg(15,12,04,16,"Mit Account anmelden")
  369.     msg(01,13,04,16,"---------------------------------------------------")
  370.     msg(15,14,15,15,"                     ")
  371.     msg(15,15,15,15,"                     ") msg(20,15,01,15,"klick hier") 
  372.     msg(15,16,15,15,"                     ")
  373.     msg(01,17,04,16,"---------------------------------------------------")
  374.     msg(01,20,04,16," ")
  375.  
  376.     local event, button, X, Y = os.pullEvent("mouse_click")
  377.     if X >= 15 and X <= 34 and Y >= 05 and Y <= 07 then
  378.         neueracc()
  379.     elseif X >= 15 and X <= 34 and Y >= 14 and Y <= 16 then
  380.         anmelden()
  381.     else
  382.         start()
  383.     end
  384. end
  385.  
  386. start()
Add Comment
Please, Sign In to add comment