Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- IDTerminal = 909
- rednet.open("back")
- local psd = ""
- local motdepasse = ""
- local hideMdp = ""
- local CompteValider=false
- local historique = {}
- local solde = 0
- local Action="Connection"
- local nomTransfer = ""
- local sommeTransfer = 0
- function Deconnection()
- info = {Act="Deconnection"}
- infos = textutils.serialise(info)
- rednet.send(IDTerminal,infos)
- end
- function updateInfo()
- info = {Act="ActualiserC",Proprio=psd}
- infos = textutils.serialise(info)
- rednet.send(IDTerminal, infos)
- os.pullEvent("updateInfoReceive")
- end
- function unfocusText()
- event, button, x, y = os.pullEvent("mouse_click")
- os.queueEvent("key",28)
- sleep(0.01)
- os.queueEvent("mouse_click",button,x,y)
- os.queueEvent("unfocusText")
- end
- function DrawMenuTransfers()
- shell.run("clear")
- img = paintutils.loadImage("MenuTransfers")
- paintutils.drawImage(img,1,1)
- term.setCursorPos(2,1)
- term.setBackgroundColor(colors.gray)
- term.setTextColor(colors.yellow)
- print("Bienvenue "..psd..", Votre solde : "..solde)
- term.setCursorPos(5,3)
- term.setBackgroundColor(colors.lightGray)
- term.setTextColor(colors.black)
- print("*J/E : "..nomTransfer)
- term.setCursorPos(40,3)
- print(sommeTransfer)
- term.setCursorPos(41,5)
- term.setBackgroundColor(colors.green)
- term.setTextColor(colors.yellow)
- print("Valider")
- term.setBackgroundColor(colors.lightGray)
- term.setCursorPos(5,5)
- print("Historique :")
- term.setCursorPos(41,15)
- term.setBackgroundColor(colors.orange)
- print("Annuler")
- term.setCursorPos(41,17)
- term.setBackgroundColor(colors.red)
- print("Retour")
- term.setCursorPos(4,17)
- term.setTextColor(colors.black)
- term.setBackgroundColor(colors.white)
- print("*J/E = Joueur/Entreprise")
- term.setTextColor(colors.yellow)
- term.setBackgroundColor(colors.gray)
- drawHistorique(4,6,10)
- end
- function DrawMenuEntreprise()
- img = paintutils.loadImage("MenuEntreprise")
- paintutils.drawImage(img,1,1)
- term.setCursorPos(3,4)
- term.setTextColor(colors.yellow)
- term.setBackgroundColor(colors.lightGray)
- print("Cree Entreprise")
- term.setCursorPos(3,6)
- print("Retirer Entreprise")
- term.setCursorPos(3,8)
- print("Ajouter Membres")
- term.setCursorPos(3,10)
- print("Retirer Membres")
- end
- function DrawMenuConnection()
- shell.run("clear")
- img = paintutils.loadImage("MenuConnection")
- paintutils.drawImage(img,1,1)
- term.setCursorPos(2,1)
- term.setTextColor(colors.yellow)
- term.setBackgroundColor(colors.gray)
- print("Bienvenue sur l'ATM de la banque")
- term.setTextColor(colors.black)
- term.setBackgroundColor(colors.lightGray)
- term.setCursorPos(12,8)
- print("Pseudo : "..psd)
- term.setCursorPos(14,11)
- hideMdp = ""
- for i =1,#motdepasse do
- hideMdp = hideMdp.."*"
- end
- print("Code : "..hideMdp)
- term.setTextColor(colors.yellow)
- term.setCursorPos(13,13)
- term.setBackgroundColor(colors.red)
- print("Annuler")
- term.setCursorPos(31,13)
- term.setBackgroundColor(colors.lime)
- print("Valider")
- term.setTextColor(colors.black)
- end
- function drawHistorique(x,y,lignesMax)
- for i = 0, lignesMax do
- term.setCursorPos(x,y+i)
- if historique[#historique-i] == nil then
- else
- print(historique[#historique-i])
- end
- end
- end
- function DrawMenuPrincipal()
- img = paintutils.loadImage("MenuPrincipal")
- paintutils.drawImage(img,1,1)
- term.setCursorPos(2,1)
- term.setTextColor(colors.yellow)
- term.setBackgroundColor(colors.gray)
- print("Bienvenue "..psd..", Votre solde : "..solde)
- term.setBackgroundColor(colors.lightGray)
- term.setCursorPos(15,4)
- print("Historique : ")
- term.setCursorPos(3,4)
- print("Transferer")
- term.setCursorPos(3,6)
- print("Entreprise")
- term.setCursorPos(41,17)
- term.setBackgroundColor(colors.red)
- print("Quitter")
- term.setBackgroundColor(colors.lightGray)
- term.setTextColor(colors.yellow)
- term.setCursorPos(14,17)
- print(" Effacer l'Historique")
- term.setBackgroundColor(colors.gray)
- term.setTextColor(colors.yellow)
- drawHistorique(14,5,10)
- end
- function MenuAff()
- if Action == "Connection" then
- DrawMenuConnection()
- elseif Action == "MenuPrincipal" then
- DrawMenuPrincipal()
- elseif Action == "MenuTransfers" then
- DrawMenuTransfers()
- elseif Action == "MenuEntreprise" then
- DrawMenuEntreprise()
- end
- end
- function startup()
- Deconnection()
- MenuAff()
- while true do
- event, p1, p2, p3 = os.pullEvent()
- if event == "mouse_click" then
- term.setTextColor(colors.black)
- print("X:"..p2.." Y:"..p3)
- if Action == "Connection" then
- if p2 >= 28 and p2 <= 39 and p3 == 13 then
- info = {Act="Connection",Pseudo=psd,Mdp=motdepasse}
- infos = textutils.serialise(info)
- rednet.send(IDTerminal, infos)
- elseif p2 >= 20 and p2 <= 39 and p3 == 8 then
- function PseudoRead()
- psd=""
- MenuAff()
- term.setCursorPos(21,8)
- term.setBackgroundColor(colors.lightGray)
- write("")
- psd = read()
- os.queueEvent("mouse_click",1,0,0)
- end
- parallel.waitForAll(PseudoRead, unfocusText)
- elseif p2 >= 20 and p2 <= 39 and p3 == 11 then
- function mdpRead()
- motdepasse=""
- MenuAff()
- term.setCursorPos(21,11)
- term.setBackgroundColor(colors.lightGray)
- write("")
- motdepasse = read("*")
- os.queueEvent("mouse_click",1,0,0)
- end
- parallel.waitForAll(mdpRead,unfocusText)
- elseif p2 >= 11 and p2 <= 22 and p3 == 13 then
- psd=""
- motdepasse=""
- CompteValider=false
- historique={}
- solde=0
- sommeTransfer = 0
- nomTransfer = ""
- MenuAff()
- end
- elseif Action == "MenuPrincipal" then
- if p2 >= 2 and p2 <= 12 and p3 == 4 then
- Action = "MenuTransfers"
- updateInfo()
- elseif p2 >= 2 and p2 <= 12 and p3 == 6 then
- Action = "MenuEntreprise"
- updateInfo()
- elseif p2 >= 14 and p2 <= 34 and p3 == 17 then
- info = {Act="EffHistorique",Pseudo=psd}
- infos = textutils.serialise(info)
- rednet.send(IDTerminal, infos)
- elseif p2 >= 40 and p2 <= 48 and p3 == 17 then
- Action = "Connection"
- Deconnection()
- psd=""
- motdepasse=""
- CompteValider=false
- historique = {}
- solde = 0
- nomTransfer = ""
- sommeTransfer = 0
- MenuAff()
- end
- elseif Action == "MenuTransfers" then
- if p2 >= 40 and p2 <= 48 and p3 == 17 then
- Action = "MenuPrincipal"
- updateInfo()
- elseif p2 >= 11 and p2 <= 38 and p3 == 3 then
- nomTransfer = ""
- updateInfo()
- function ReadNom()
- term.setCursorPos(12,3)
- term.setBackgroundColor(colors.lightGray)
- term.setTextColor(colors.black)
- write("")
- nomTransfer = read()
- os.queueEvent("mouse_click",1,0,0)
- end
- parallel.waitForAll(ReadNom,unfocusText)
- elseif p2 >= 40 and p2 <= 48 and p3 == 3 then
- local nSomme = ""
- sommeTransferSave = sommeTransfer
- sommeTransfer = ""
- updateInfo()
- sommeTransfer = sommeTransferSave
- function ReadSomme()
- term.setCursorPos(40,3)
- term.setBackgroundColor(colors.lightGray)
- term.setTextColor(colors.black)
- write("")
- nSomme = read()
- os.queueEvent("mouse_click",1,0,0)
- end
- parallel.waitForAll(ReadSomme,unfocusText)
- if tonumber(nSomme) then
- sommeTransfer = nSomme + 0
- if sommeTransfer+0 > solde+0 then
- sommeTransfer = solde+0
- end
- end
- MenuAff()
- elseif p2 >= 40 and p2 <= 48 and p3 == 15 then
- sommeTransfer= 0
- nomTransfer = ""
- updateInfo()
- elseif p2 >= 40 and p2 <= 48 and p3 == 5 then
- info = {Act="Transfer",Proprio=psd,Destinataire=nomTransfer,Somme=sommeTransfer}
- infos = textutils.serialise(info)
- rednet.send(IDTerminal, infos)
- end
- end
- end
- end
- end
- function Reception()
- while true do
- ID, info = rednet.receive()
- print(ID)
- if ID == IDTerminal then
- infos = textutils.unserialise(info)
- if infos.Act == "CompteValide" then
- CompteValider=true
- Action="MenuPrincipal"
- solde = infos.Solde
- historique = textutils.unserialise(infos.Historique)
- MenuAff()
- elseif infos.Act == "CompteNValide" then
- CompteValider=false
- Action="Connection"
- term.setCursorPos(11,15)
- term.setTextColor(colors.red)
- term.setBackgroundColor(colors.white)
- print("Mauvais Pseudo/Mot de passe !")
- elseif infos.Act== "Actualiser" then
- solde = infos.Solde
- historique = textutils.unserialise(infos.Historique)
- MenuAff()
- os.queueEvent("updateInfoReceive")
- end
- end
- end
- end
- function diskEject()
- while true do
- event, side = os.pullEvent("disk")
- disk.eject(side)
- end
- end
- parallel.waitForAll(startup,Reception,diskEject)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement