Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 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>')
- x = 0;
- y = 0;
- a = 0;
- l = 0;
- function eventNewGame()
- for xml in tfm.get.room.xmlMapInfo.xml:gmatch("<S[^/]+/>") do
- if xml:match('T="(%d+)"') == "8" then -- Ve se o piso é nuvem **tonumber() é usado para converter string para um número int
- x=tonumber(xml:match('X="(%d+)"')); -- Pega a posição x do piso
- y=tonumber(xml:match('Y="(%d+)"')); -- Pega a posição y do piso
- a=tonumber(xml:match('H="(%d+)"')); -- Pega a altura do piso
- l=tonumber(xml:match('L="(%d+)"')); -- Pega a largura do piso
- end
- end
- end
- function xPosition(p)
- 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
- return true -- Retorna true
- end
- end
- function yPosition(p)
- 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
- return true -- Retorna true
- end
- end
- function eventLoop(ct,rt)
- for i in pairs(tfm.get.room.playerList) do
- if xPosition(i) == true and yPosition(i) == true then -- Verifica se algum jogador está
- tfm.exec.giveCheese(i) -- Dar o queijo se o jogador está na posição x e y do piso
- end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment