Clem105

Computer inscription

Apr 6th, 2016
112
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.18 KB | None | 0 0
  1. m = peripheral.wrap("bottom")
  2. m.open(6105)
  3.  
  4.  
  5. function main()
  6.     term.clear()
  7.     term.setCursorPos(16,3)
  8.     term.write("Bienvenue dans le Game")
  9.     term.setCursorPos(15,7)
  10.     term.write("Que voulez vous faire ?")
  11.     term.setCursorPos(10,13)
  12.     term.write("M'inscrire")
  13.     term.setCursorPos(26,13)
  14.     term.write("Me désinscrire")
  15.     while true do
  16.         event,click,x,y = os.pullEvent("mouse_click")
  17.         if x>9 and x<17 and y>12 and y<15 then
  18.             Register()
  19.         elseif x>25 and x<33 and y>12 and y<15 then
  20.             Cancel()
  21.         end
  22.     sleep(0.1)
  23.     end
  24. end
  25.  
  26.  
  27. function Register()
  28.     term.clear()
  29.     term.setCursorPos(15,7)
  30.     term.write("Pseudo :")
  31.     pseudo = read()
  32.     msg = textutils.serialize({pseudo,"w"})
  33.     m.transmit(6105,4,msg)
  34.     sleep(2)
  35.     main()
  36. end
  37.  
  38. function Cancel()
  39.     term.clear()
  40.     term.setCursorPos(15,7)
  41.     term.write("Pseudo :")
  42.     pseudo = read()
  43.     msg = textutils.serialize({pseudo,"rm"})
  44.     m.transmit(6105,4,msg)
  45.     event,side,channel,channelbis,message = os.pullEvent("modem_message")
  46.     if message == "ok" then
  47.         sleep(2)
  48.         main()
  49.     elseif message == "non" then
  50.         term.clear()
  51.         term.setCursorPos(12,7)
  52.         term.write("Mauvais pseudo veuillez recommencer")
  53.         sleep(2)
  54.         main()
  55.     end
  56. end
  57.  
  58. main()
Advertisement
Add Comment
Please, Sign In to add comment