Brenower

xml 1

Feb 20th, 2014
196
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.49 KB | None | 0 0
  1. tfm.exec.newGame('<C><P /><Z><S><S H="80" P="0,0,0.3,0.2,0,0,0,0" L="800" X="400" Y="400" T="6" /><S H="50" P="0,0,0.3,0.2,0,0,0,0" L="50" X="400" Y="335" T="8" /></S><D /><O /></Z></C>')
  2.  
  3. x = 0;
  4. y = 0;
  5. a = 0;
  6. l = 0;
  7.  
  8. function eventNewGame()
  9.     for xml in tfm.get.room.xmlMapInfo.xml:gmatch("<S[^/]+/>") do
  10.         if xml:match('T="(%d+)"') == "8" then -- Ve se o piso é nuvem **tonumber() é usado para converter string para um número int
  11.             x=tonumber(xml:match('X="(%d+)"')); -- Pega a posição x do piso
  12.             y=tonumber(xml:match('Y="(%d+)"')); -- Pega a posição y do piso
  13.             a=tonumber(xml:match('H="(%d+)"')); -- Pega a altura do piso
  14.             l=tonumber(xml:match('L="(%d+)"')); -- Pega a largura do piso
  15.         end
  16.     end
  17. end
  18.  
  19. function xPosition(p)
  20.     if tfm.get.room.playerList[p].x > x - l and tfm.get.room.playerList[p].x < x + l then -- Verifica se o jogador está na posição do piso, veja que a largura do piso é utilizada para isso
  21.         return true -- Retorna true
  22.     end
  23. end
  24.  
  25. function yPosition(p)
  26.     if tfm.get.room.playerList[p].y > y - a and tfm.get.room.playerList[p].y < y + a then -- Verifica se o jogador está na posição y do piso, veja que a altura do piso é utilizada para isso
  27.         return true -- Retorna true
  28.     end
  29. end
  30.  
  31. function eventLoop(ct,rt)
  32.     for i in pairs(tfm.get.room.playerList) do
  33.         if xPosition(i) == true and yPosition(i) == true then -- Verifica se algum jogador está
  34.             tfm.exec.giveCheese(i) -- Dar o queijo se o jogador está na posição x e y do piso
  35.         end
  36.     end
  37. end
Advertisement
Add Comment
Please, Sign In to add comment