Muzze77

BankSysTest

Mar 24th, 2014
407
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 5.75 KB | None | 0 0
  1.  
  2.     os.loadAPI("ocs/apis/sensor")
  3.     side = "top"
  4.     key = theKey
  5.      
  6.     local s = sensor.wrap(side)
  7.     local t = s.getTargets()
  8.     local d = s.getTargetDetails("-2,-1,1")    
  9.     local coins = 0
  10.     function cut()
  11.         sleep(3)
  12.         shell.run("clear")
  13.         sleep(1)
  14.     end
  15.  
  16. function start()
  17.     shell.run("clear")
  18.     sleep(0.2)
  19.     term.setBackgroundColor(colors.blue)
  20.     term.setTextColor(colors.white)
  21.     shell.run("clear")
  22.     sleep(0.2)
  23.     print("   Willkommen in der Macebank Manarola")
  24.     print("         Mit W zugriff aufs Terminal")
  25.     TerminalStart()
  26.    
  27. end
  28.    
  29. function TerminalStart()
  30.         local evt, key = os.pullEvent("char")
  31.         key = string.lower(key)
  32.         if key == "w" then
  33.             cut()
  34.             print("     Bitte waehle eine Aktion:\n     [L]Lade Account\n       [N]Erstelle Neuen Account")
  35.             LoadNew()
  36.         else
  37.  
  38.         end
  39.        
  40. end
  41.    
  42. function LoadNew()
  43.         local evt, key1 = os.pullEvent("char")
  44.             key1 = string.lower(key1)
  45.             if key1 == "l" then
  46.             load()
  47.             elseif key1 == "n" then
  48.             new()
  49.             else
  50.  
  51.             end
  52. end
  53. function auslesen()
  54.     for k,v in pairs(d.Slots) do
  55.         if (v.Name == "Industrial Credit") then
  56.             coins = coins + v.Size  
  57.             print(coins .. " Muenzen in der Kiste")
  58.                 if coins >= einz then
  59.                     while iso ~= 0 do
  60.                         shell.run("clear")  
  61.                         rs.setBundledOutput("back", colors.blue)
  62.                         sleep(2)
  63.                         iso = iso - 1
  64.                         print(iso .. " Industrial Credits noch")
  65.                         rs.setBundledOutput("back", 0) 
  66.                         sleep(0.2) 
  67.                     end
  68.                         if c == nil then
  69.                             c = 0
  70.                         else
  71.                             print(c)
  72.                             sleep(2)
  73.                             shell.run("clear")
  74.                         end
  75.                     load = einz + c
  76.                     wfile1 = fs.open(tostring(user), "w")
  77.                     wfile1.writeLine(tostring(user))
  78.                     wfile1.writeLine(tostring(pass))
  79.                     wfile1.writeLine(tostring(load))
  80.                     wfile1.close()
  81.                     print(c2  .. "$ wurde eingezahlt  = " .. einz .. " Industrial Credits")
  82.                     sleep(2)   
  83.                     print("Beehren Sie uns bald wieder")
  84.                     sleep(2)
  85.                     cut()
  86.                 else
  87.                     print("Nicht genug Industrial Credits in der Kiste")
  88.                     sleep(2)
  89.                
  90.                 end
  91.            
  92.         else
  93.         print("falsche Items in der Kiste")
  94.         sleep(2)
  95.        
  96.         end
  97.        
  98.     end
  99. end  
  100. function Auszahlen()
  101.     print("Wie viel wollen Sie Auszahlen?:")
  102.     ausz = io.read()
  103.     count = ausz
  104.     if c < count then
  105.         print("Nicht genug Industrial Coins auf deinem Konto")
  106.         sleep(2)
  107.     else
  108.         shell.run("clear")
  109.         rs.setBundledOutput("back", colors.red)
  110.         while count ~= 0 do
  111.         print( count .. " Industrial Coins werden noch Ausgezahlt")
  112.         sleep(2)
  113.         shell.run("clear")
  114.         count = count - 1
  115.         end
  116.         print("Industrial Coins wurden ausgezahlt. Bitte auf den rechten Knopf drücken.!")
  117.         print("Beehren Sie uns bald wieder")
  118.         sleep(2)
  119.         mon = c - ausz
  120.        
  121.         sfile1 = fs.open(user, "w")
  122.         sfile1.writeLine(user)
  123.         sfile1.writeLine(pass)
  124.         sfile1.writeLine(mon)
  125.         sfile1.close()
  126.         shell.run("clear")
  127.         sleep(10)
  128.    
  129.     end
  130. end
  131. function Einzahlen()
  132.         print("     Wie viel wollen Sie einzahlen? In Industrial Credits angeben?")
  133.         print("     1 IC2 Industrial Muenze entspricht 50$ ")
  134.         print("     Maximal 200 IC2 Industrial Credits anlegbar = 10.000$")
  135.         einz = tonumber(read())
  136.         if einz >= 200 then
  137.             print("Zu viele Muenzen bitte weniger waehlen")
  138.                                            
  139.         else
  140.             print("Muenzen jetzt in die Obsidian Pipe werfen")
  141.             print("Wirklich Industrial Credits einzahlen ? [J]|[N]")
  142.             local evt, key3 = os.pullEvent("char")
  143.             key3 = string.lower(key3)
  144.                 if key3 == "j" then
  145.                     number = einz
  146.                     iso = number
  147.                     c2 = iso*50
  148.                     auslesen()
  149.                 elseif key3 == "n" then
  150.                     print("Auf Wiedersehen")
  151.                     sleep(2)
  152.                     cut()
  153.                 else
  154.                
  155.                 end
  156.         end
  157.  
  158. end
  159.  
  160.  
  161.  
  162.  
  163.  
  164.  
  165. function Kontostand()
  166.     print(" Ihr Kontostand beträgt ".. tostring(c) .. " Industrial Coins")
  167.     sleep(2)
  168.    
  169.    
  170. end
  171.  
  172. function load()
  173.         shell.run("clear")
  174.         print("     Bitte Usernamen eingeben: ")
  175.         user = io.read()
  176.         dem = fs.exists(user)
  177.             if dem == true then
  178.                             rfile = fs.open(user, "r")
  179.                             a = rfile.readLine(1)
  180.                             b = rfile.readLine(2)
  181.                             c = rfile.readLine(3)
  182.                             rfile.close()
  183.            
  184.                         if user == a then
  185.                             print("     Bitte Password eingeben")
  186.                             pass = read("*")   
  187.                                 if pass == b then
  188.                                     print("Password Akzeptiert")
  189.                                     cut()
  190.                                     print("     Welche Aktion wollen Sie ausfuehren?")
  191.                                     print("     [e]Einzahlen\n      [a]Auszahlen\n      [k]Kontostand")
  192.                                    
  193.                                     local evt, key2 = os.pullEvent("char")
  194.                                     key2 = string.lower(key2)
  195.                                         if key2 == "e" then
  196.                                         Einzahlen()
  197.                                         elseif key2 == "a" then
  198.                                         Auszahlen()
  199.                                         elseif key2 == "k" then
  200.                                         Kontostand()
  201.                                         else
  202.                                            
  203.                                         end
  204.                                 else
  205.                                     print("     Falsches Passwort")
  206.                                     sleep(2)
  207.                                 end
  208.                         else
  209.                             print("     Falscher Username")
  210.                             sleep(2)
  211.                            
  212.                            
  213.                         end
  214.             elseif dem == false then
  215.             print("     Der Account " .. user .. " exsistiert nicht")
  216.             sleep(2)
  217.            
  218.             end
  219. end
  220.    
  221.    
  222. function new()
  223.         print("     Namen Eingeben :")
  224.                 Name = io.read()
  225.                 if fs.exists(Name) then
  226.                     print("     Account existiert bereits")
  227.                     print("     Bitte waehlen Sie einen anderen Accountnamen")
  228.                    
  229.                 else
  230.                     print("Name " .. Name .. " gewaehlt")
  231.                     sleep(2)
  232.                     cut()
  233.                     print("Password Eingeben")
  234.                     Password = read("*")
  235.                     cut()
  236.                     acc = {}
  237.                     acc.Name = {}
  238.                     acc.Name.Name = Name
  239.                     acc.Name.Password = Password
  240.                     acc.Name.Muenzen = 0
  241.                     file = fs.open(Name, "w")
  242.                     file.writeLine(acc.Name.Name)
  243.                     file.writeLine(acc.Name.Password)
  244.                     file.writeLine(acc.Name.Muenzen)
  245.                     file.close()
  246.                     print(" Done!")
  247.                     print(" Name: " .. acc.Name.Name .. " Account erstellt.")
  248.                     print(" Industrial Coins : " .. acc.Name.Muenzen )
  249.                     sleep(2)
  250.                     cut()
  251.                 end
  252. end            
  253.  
  254.  
  255.  
  256.  
  257. while true do
  258.  
  259. start()
  260.  
  261. end
Add Comment
Please, Sign In to add comment