Advertisement
AdslHouba

Course : computercraft

Apr 26th, 2018
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.34 KB | None | 0 0
  1. local mani=peripheral.wrap("manipulator_0")
  2. local mani2=peripheral.wrap("manipulator_1")
  3. local joueurs={}
  4. local pasAccepter={
  5.     ["item"]=true,
  6.     ["Item"]=true,
  7.     ["Sheep"]=true,
  8.     ["Boat"]=true
  9. }
  10. local ecran1=peripheral.wrap("monitor_13")
  11. local ecran2=peripheral.wrap("monitor_14")
  12.  
  13. function boucleDepart()
  14.     while true do
  15.        local liste=mani.sense()
  16.        local listeT=#liste
  17.        for i=1,listeT do
  18.          if pasAccepter[liste[i].name] then
  19.          else
  20.              if joueurs[liste[i].name] then
  21.              else
  22.                  if liste[i].y<1 and liste[i].y>-4 and liste[i].x<1 and liste[i].x>-3 and liste[i].z<-1 and liste[i].z>-8 then
  23.                      joueurs[liste[i].name]=true
  24.                      http.request("http://www.adslhoube.fr/boat.php?type=depart&pseudo="..liste[i].name)                    
  25.                  end
  26.              end
  27.            end
  28.         end
  29.     end
  30. end
  31.  
  32. function boucleFin()
  33.     while true do
  34.        local liste=mani2.sense()
  35.        local listeT=#liste
  36.        for i=1,listeT do  
  37.           if joueurs[liste[i].name] then
  38.                  if liste[i].y<1 and liste[i].y>-4 and liste[i].x<13.5 and liste[i].x>10.5 and liste[i].z<0 and liste[i].z>-7 then
  39.                      joueurs[liste[i].name]=false
  40.                      http.request("http://www.adslhoube.fr/boat.php?type=arriver&pseudo="..liste[i].name)
  41.                  end
  42.            end
  43.         end
  44.     end
  45. end
  46.  
  47. function eventboucle()
  48.   while true do
  49.     local event, url, sourceText = os.pullEvent()
  50.     if event == "http_success" then
  51.        local donne= sourceText.readAll()
  52.        donne=textutils.unserialize(donne)
  53.        ecranGo(ecran1,donne)
  54.        ecranGo(ecran2,donne)      
  55.        sourceText.close()      
  56.     end
  57.   end
  58. end
  59.  
  60. function ecranGo(ecran,donne)
  61.    ecran.clear()
  62.    ecran.setCursorPos(1,1)
  63.    local y=1
  64.    ecran.write("Record")
  65.    for i=1,#donne.record do
  66.        y=y+1
  67.        ecran.setCursorPos(1,y)
  68.        ecran.write(i.." "..donne.record[i].pseudo.." "..donne.record[i].scoreMin)
  69.     end
  70.    y=y+2
  71.    ecran.setCursorPos(1,y)
  72.    ecran.write("dernier score")
  73.    for i=1,#donne.dernier do
  74.        y=y+1
  75.        ecran.setCursorPos(1,y)
  76.        ecran.write(donne.dernier [i].pseudo.." "..donne.dernier[i].score)
  77.     end
  78. end
  79.  
  80. http.request("http://www.adslhoube.fr/boat.php?type=affichage")
  81. parallel.waitForAll(boucleDepart, boucleFin,eventboucle)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement