Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local args = {...}
- if not fs.exists("arcui") or args[1] == "true" then
- print("Downloading arcUI...")
- shell.run("pastebin get NuZUGEmn arcui")
- end
- os.loadAPI("arcui")
- if not fs.exists("json") or args[1] == "true" then
- print("Downloading json...")
- shell.run("pastebin get 4nRg9CHU json")
- end
- os.loadAPI("json")
- local monX, monY = term.getSize()
- local PASSWORD = nil
- local USERNAME = nil
- function db()
- url = "http://r3dsky.minesylv.be/bank/api.php?action=register&user="..USERNAME.."&password="..PASSWORD
- db = http.get(url).readAll()
- obj = json.decode(db)
- end
- function creacompte(monX, monY)
- local monX, monY = term.getSize()
- arcui.drawWindow("Création d'un nouveau compte bancaire ",false)
- arcui.drawLabel('Name',2,3,"Nom du compte",colors.grey)
- arcui.drawTextbox('NAME',2,4,monX / 2 - 9 ,"ex:Michelin")
- arcui.drawLabel('Firstname',30,3,"Prénom du compte",colors.grey)
- arcui.drawTextbox('FIRSTNAME',30,4,40,"ex:Pascal")
- arcui.drawLabel('PASS',2,6,"Définir un code PIN",colors.grey)
- arcui.drawTextbox('PASSWORD',2,7,monX / 2 - 9 ,"ex:1234")
- arcui.drawLabel('PASSCONFIRM',2,9,"Confirmer le code PIN",colors.grey)
- arcui.drawTextbox('PASSWORDCONFIRM',2,10,monX / 2 - 9 ,"ex:1234")
- arcui.drawButton("confirm_btn", 1, monY, monX, monY, colors.green, "Valider le compte")
- end
- function crea()
- while true do
- event, a1, a2, a3 = os.pullEvent()
- if a1 == "PASSWORD" then
- if a2 == "" then
- --Do nothing
- elseif not tonumber(a2) then
- arcui.openDialog("PASSWORD_dialog", "Code invalide", " Le code doit être composé de chiffres !")
- arcui.redrawWindow("Création d'un nouveau compte bancaire ")
- arcui.changeValue("PASSWORD", "value", "")
- elseif #a2 ~= 4 then
- arcui.openDialog("PASSWORD_dialog", "Code invalide", " Le code doit faire 4 chiffres !")
- arcui.redrawWindow("Création d'un nouveau compte bancaire ")
- arcui.changeValue("PASSWORD", "value", "")
- else
- PASSWORD = tonumber(a2)
- end
- elseif a1 == "PASSWORDCONFIRM" then
- if a2 == "" then
- --Do nothing
- elseif not tonumber(a2) then
- arcui.openDialog("PASSWORD_dialog", "Code invalide", " Le code doit être composé de chiffres !")
- arcui.redrawWindow("Création d'un nouveau compte bancaire ")
- arcui.changeValue("PASSWORD", "value", "")
- else
- PASSWORDCONFIRM = tonumber(a2)
- end
- elseif a1 == "NAME" then
- if a2 == "" then
- --Do nothing
- elseif #a2 <= 4 then
- arcui.openDialog("USERNAME_dialog", "Nom invalide", " Le nom du compte doit faire plus de 4 lettres.")
- arcui.redrawWindow("Création d'un nouveau compte bancaire ")
- arcui.changeValue("USERNAME", "value", "")
- else
- NAME = a2
- end
- elseif a1 == "FIRSTNAME" then
- if a2 == "" then
- --Do nothing
- elseif #a2 <= 4 then
- arcui.openDialog("USERNAME_dialog", "Prénom invalide", " Le nom du compte doit faire plus de 4 lettres.")
- arcui.redrawWindow("Création d'un nouveau compte bancaire ")
- arcui.changeValue("FIRSTNAME", "value", "")
- else
- FIRSTNAME = a2
- end
- elseif event == "button_clicked" then
- if a1 == "confirm_btn" then
- if not PASSWORD then
- arcui.openDialog("confirm_dialog", "Quelque chose manque..", " Vous devez entrer un code PIN !")
- arcui.redrawWindow("Création d'un nouveau compte bancaire ")
- elseif not NAME then
- arcui.openDialog("confirm_dialog", "Quelque chose manque..", " Vous devez entrer un nom de compte !")
- arcui.redrawWindow("Création d'un nouveau compte bancaire ")
- elseif not FIRSTNAME then
- arcui.openDialog("confirm_dialog", "Quelque chose manque..", " Vous devez entrer un prénom de compte !")
- arcui.redrawWindow("Création d'un nouveau compte bancaire ")
- elseif PASSWORDCONFIRM ~= PASSWORD then
- arcui.openDialog("confirm_dialog", "Quelque chose manque..", " Vous devez entrer le même code PIN !")
- arcui.redrawWindow("Création d'un nouveau compte bancaire ")
- else
- rep = arcui.openDialog("confirm_dialog", "Sauvegarder le compte", " Voulez-vous vraiment enregistrer ce compte ?")
- arcui.redrawWindow("Création d'un nouveau compte bancaire ")
- end
- end
- end
- end
- end
- parallel.waitForAll(crea, creacompte, arcui.eventHandler)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement