Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- PROGRAMME CAISSE --
- -- PARTIE 1 --
- -- INSTALLATION DES APIS/HARDWARE --
- local args = {...}
- local monX, monY = term.getSize()
- local PASSWORD = nil
- local USERNAME = nil
- local NAME = nil
- local FIRSTNAME = nil
- if not fs.exists("BSAPI") or args[1] == "true" then
- shell.run("pastebin get 1CFqeP11 BSAPI")
- end
- if not fs.exists("json") or args[1] == "true" then
- shell.run("pastebin get 4nRg9CHU json")
- end
- os.loadAPI("BSAPI")
- os.loadAPI("json")
- for a,b in pairs(rs.getSides()) do
- if peripheral.getType(b) == 'modem' then
- rednet.open(b)
- break
- end
- end
- for a,b in pairs(rs.getSides()) do
- if peripheral.getType(b) == 'printer' then
- printer = peripheral.wrap(b)
- break
- end
- end
- -- PARTIE 2 --
- -- LAUNCHER --
- function launchercaisse(monX, monY)
- local monX, monY = term.getSize()
- BSAPI.drawWindow("Création d'un nouveau compte caisse ",false)
- BSAPI.drawLabel('Name',2,3,"Nom",colors.grey)
- BSAPI.drawTextbox('NAME',2,4,monX / 2 - 9 ,"ex:Michelin")
- BSAPI.drawLabel('Firstname',30,3,"Prénom",colors.grey)
- BSAPI.drawTextbox('FIRSTNAME',30,4,40,"ex:Pascal")
- BSAPI.drawLabel('PASS',2,6,"Définir un code PIN",colors.grey)
- BSAPI.drawTextbox('PASSWORD',2,7,monX / 2 - 9 ,"ex:1234")
- BSAPI.drawLabel('PASSCONFIRM',2,9,"Confirmer le code PIN",colors.grey)
- BSAPI.drawTextbox('PASSWORDCONFIRM',2,10,monX / 2 - 9 ,"ex:1234")
- BSAPI.drawButton("confirm_btn", 1, monY, monX, monY, colors.green, "Valider le compte")
- end
- function launchercaisse2()
- while true do
- event, a1, a2, a3 = os.pullEvent()
- if a1 == "PASSWORD" then
- if a2 == "" then
- --Do nothing
- elseif not tonumber(a2) then
- BSAPI.openDialog("PASSWORD_dialog", "Code invalide", " Le code doit être composé de chiffres !")
- BSAPI.redrawWindow("Création d'un nouveau compte bancaire ",false)
- BSAPI.changeValue("PASSWORD", "value", "")
- elseif #a2 ~= 4 then
- BSAPI.openDialog("PASSWORD_dialog", "Code invalide", " Le code doit faire 4 chiffres !")
- BSAPI.redrawWindow("Création d'un nouveau compte bancaire ",false)
- BSAPI.changeValue("PASSWORD", "value", "")
- else
- PASSWORD = tonumber(a2)
- end
- elseif a1 == "PASSWORDCONFIRM" then
- if a2 == "" then
- --Do nothing
- elseif not tonumber(a2) then
- BSAPI.openDialog("PASSWORD_dialog", "Code invalide", " Le code doit être composé de chiffres !")
- BSAPI.redrawWindow("Création d'un nouveau compte bancaire ",false)
- BSAPI.changeValue("PASSWORD", "value", "")
- else
- PASSWORDCONFIRM = tonumber(a2)
- end
- elseif a1 == "NAME" then
- if a2 == "" then
- --Do nothing
- elseif #a2 <= 4 then
- BSAPI.openDialog("USERNAME_dialog", "Nom invalide", " Le nom doit faire plus de 4 lettres.")
- BSAPI.redrawWindow("Création d'un nouveau compte bancaire ",false)
- BSAPI.changeValue("NAME", "value", "")
- elseif tonumber(a2) then
- BSAPI.openDialog("USERNAME_dialog", "Nom invalide", " Le nom doit être composé de lettres")
- BSAPI.redrawWindow("Création d'un nouveau compte bancaire ",false)
- BSAPI.changeValue("NAME", "value", "")
- else
- NAME = a2
- end
- elseif a1 == "FIRSTNAME" then
- if a2 == "" then
- --Do nothing
- elseif #a2 <= 4 then
- BSAPI.openDialog("USERNAME_dialog", "Prénom invalide", " Le prénom doit faire plus de 4 lettres.")
- BSAPI.redrawWindow("Création d'un nouveau compte bancaire ",false)
- BSAPI.changeValue("FIRSTNAME", "value", "")
- elseif tonumber(a2) then
- BSAPI.openDialog("USERNAME_dialog", "Prénom invalide", " Le prénom doit être composé de lettres")
- BSAPI.redrawWindow("Création d'un nouveau compte bancaire ",false)
- BSAPI.changeValue("FIRSTNAME", "value", "")
- else
- FIRSTNAME = a2
- end
- elseif event == "button_clicked" then
- if a1 == "confirm_btn" then
- if not PASSWORD then
- BSAPI.openDialog("confirm_dialog", "Quelque chose manque..", " Vous devez entrer un code PIN !")
- BSAPI.redrawWindow("Création d'un nouveau compte bancaire ",false)
- elseif not NAME then
- BSAPI.openDialog("confirm_dialog", "Quelque chose manque..", " Vous devez entrer un nom !")
- BSAPI.redrawWindow("Création d'un nouveau compte bancaire ",false)
- elseif not FIRSTNAME then
- BSAPI.openDialog("confirm_dialog", "Quelque chose manque..", " Vous devez entrer un prénom !")
- BSAPI.redrawWindow("Création d'un nouveau compte bancaire ",false)
- elseif PASSWORDCONFIRM ~= PASSWORD then
- BSAPI.openDialog("confirm_dialog", "Quelque chose manque..", " Vous devez entrer le même code PIN !")
- BSAPI.redrawWindow("Création d'un nouveau compte bancaire ",false)
- else
- rep = BSAPI.openDialog("confirm_dialog", "Sauvegarder le compte", " Voulez-vous vraiment enregistrer ce compte ?")
- if rep == true then
- BSAPI.closeWindow()
- sleep(1)
- else
- BSAPI.redrawWindow("Création d'un nouveau compte bancaire ",false)
- end
- end
- end
- end
- end
- end
- parallel.waitForAll(launchercaisse, launchercaisse2, BSAPI.eventHandler)
- -- PARTIE 3 --
- -- VENTE --
- function vente(monX, monY)
- local monX, monY = term.getSize()
- BSAPI.drawWindow("Caisse de "..FIRSTNAME.." "..NAME ,false)
- BSAPI.drawLabel('vente1',2,3,"Nom",colors.grey)
- BSAPI.drawTextbox('VENTE1',2,4,monX / 2 - 9 ,"ex:Michelin")
- BSAPI.drawLabel('vente2',30,3,"Prénom",colors.grey)
- BSAPI.drawTextbox('VENTE2',30,4,40,"ex:Pascal")
- BSAPI.drawLabel('vente3',2,6,"Définir un code PIN",colors.grey)
- BSAPI.drawTextbox('VENTE3',2,7,monX / 2 - 9 ,"ex:1234")
- BSAPI.drawLabel('vente4',30,6,"Prénom",colors.grey)
- BSAPI.drawTextbox('VENTE4',30,7,40,"ex:Pascal")
- BSAPI.drawLabel('vente5',2,9,"Confirmer le code PIN",colors.grey)
- BSAPI.drawTextbox('VENTE5',2,10,monX / 2 - 9 ,"ex:1234")
- BSAPI.drawLabel('vente6',30,9,"Prénom",colors.grey)
- BSAPI.drawTextbox('VENTE6',30,10,40,"ex:Pascal")
- BSAPI.drawLabel('vente7',2,12,"Confirmer le code PIN",colors.grey)
- BSAPI.drawTextbox('VENTE7',2,13,monX / 2 - 9 ,"ex:1234")
- BSAPI.drawLabel('vente8',30,12,"Prénom",colors.grey)
- BSAPI.drawTextbox('VENTE8',30,13,40,"ex:Pascal")
- BSAPI.drawLabel('modifvente1',2,15,"Nom xQté",colors.blue)
- BSAPI.drawTextbox('MODIFVENTE1',2,16,monX / 2 - 9 ,"ex:Bread x20")
- BSAPI.drawLabel('modifvente2',30,15,"Prix",colors.blue)
- BSAPI.drawTextbox('MODIFVENTE2',30,16,40,"ex:15E")
- BSAPI.drawButton("confirm_btn", 1, monY, monX, monY, colors.green, "Modifier la vente")
- end
- function vente2()
- while true do
- event, a1, a2, a3 = os.pullEvent()
- if a1 == "PASSWORD" then
- if a2 == "" then
- --Do nothing
- elseif not tonumber(a2) then
- BSAPI.openDialog("PASSWORD_dialog", "Code invalide", " Le code doit être composé de chiffres !")
- BSAPI.redrawWindow("Création d'un nouveau compte bancaire ",false)
- BSAPI.changeValue("PASSWORD", "value", "")
- elseif #a2 ~= 4 then
- BSAPI.openDialog("PASSWORD_dialog", "Code invalide", " Le code doit faire 4 chiffres !")
- BSAPI.redrawWindow("Création d'un nouveau compte bancaire ",false)
- BSAPI.changeValue("PASSWORD", "value", "")
- else
- PASSWORD = tonumber(a2)
- end
- elseif a1 == "PASSWORDCONFIRM" then
- if a2 == "" then
- --Do nothing
- elseif not tonumber(a2) then
- BSAPI.openDialog("PASSWORD_dialog", "Code invalide", " Le code doit être composé de chiffres !")
- BSAPI.redrawWindow("Création d'un nouveau compte bancaire ",false)
- BSAPI.changeValue("PASSWORD", "value", "")
- else
- PASSWORDCONFIRM = tonumber(a2)
- end
- elseif a1 == "NAME" then
- if a2 == "" then
- --Do nothing
- elseif #a2 <= 4 then
- BSAPI.openDialog("USERNAME_dialog", "Nom invalide", " Le nom doit faire plus de 4 lettres.")
- BSAPI.redrawWindow("Création d'un nouveau compte bancaire ",false)
- BSAPI.changeValue("NAME", "value", "")
- elseif tonumber(a2) then
- BSAPI.openDialog("USERNAME_dialog", "Nom invalide", " Le nom doit être composé de lettres")
- BSAPI.redrawWindow("Création d'un nouveau compte bancaire ",false)
- BSAPI.changeValue("NAME", "value", "")
- else
- NAME = a2
- end
- elseif a1 == "FIRSTNAME" then
- if a2 == "" then
- --Do nothing
- elseif #a2 <= 4 then
- BSAPI.openDialog("USERNAME_dialog", "Prénom invalide", " Le prénom doit faire plus de 4 lettres.")
- BSAPI.redrawWindow("Création d'un nouveau compte bancaire ",false)
- BSAPI.changeValue("FIRSTNAME", "value", "")
- elseif tonumber(a2) then
- BSAPI.openDialog("USERNAME_dialog", "Prénom invalide", " Le prénom doit être composé de lettres")
- BSAPI.redrawWindow("Création d'un nouveau compte bancaire ",false)
- BSAPI.changeValue("FIRSTNAME", "value", "")
- else
- FIRSTNAME = a2
- end
- elseif event == "button_clicked" then
- if a1 == "confirm_btn" then
- if not PASSWORD then
- BSAPI.openDialog("confirm_dialog", "Quelque chose manque..", " Vous devez entrer un code PIN !")
- BSAPI.redrawWindow("Création d'un nouveau compte bancaire ",false)
- elseif not NAME then
- BSAPI.openDialog("confirm_dialog", "Quelque chose manque..", " Vous devez entrer un nom !")
- BSAPI.redrawWindow("Création d'un nouveau compte bancaire ",false)
- elseif not FIRSTNAME then
- BSAPI.openDialog("confirm_dialog", "Quelque chose manque..", " Vous devez entrer un prénom !")
- BSAPI.redrawWindow("Création d'un nouveau compte bancaire ",false)
- elseif PASSWORDCONFIRM ~= PASSWORD then
- BSAPI.openDialog("confirm_dialog", "Quelque chose manque..", " Vous devez entrer le même code PIN !")
- BSAPI.redrawWindow("Création d'un nouveau compte bancaire ",false)
- else
- rep = BSAPI.openDialog("confirm_dialog", "Sauvegarder le compte", " Voulez-vous vraiment enregistrer ce compte ?")
- if rep == true then
- BSAPI.closeWindow()
- else
- BSAPI.redrawWindow("Création d'un nouveau compte bancaire ",false)
- end
- end
- end
- end
- end
- end
- parallel.waitForAll(vente, vente2, BSAPI.eventHandler)
Add Comment
Please, Sign In to add comment