Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- data={}; -- Dados de cada jogador
- x={}; -- Posições x do +1
- y={}; -- Posições y do +1
- tfm.exec.newGame('<C><P defilante="0,0,0,1" /><Z><S><S P="0,0,0.3,0,0,0,0,0" L="800" H="80" X="400" Y="400" T="10" /></S><D /><O><O X="401" C="6" Y="344" P="0" /></O></Z></C>')
- function giveData(p) -- Dar data aos jogadores
- data[p]={
- x={};
- y={};
- }
- end
- function yPostion(p) -- Verifica se jogador está na posição y certa
- for i = #data[p].y,1,-1 do
- if tfm.get.room.playerList[p].y > data[p].y[i] - 30 and tfm.get.room.playerList[p].y < data[p].y[i] + 30 then
- table.remove(data[p].x,i) -- O jogador não pode ganhar mais pontos depois de pegar aquele +1
- table.remove(data[p].y,i)
- tfm.exec.setPlayerScore(p,1,true)
- end
- end
- end
- function xPosition(p) -- Verifica se o jogador está na posição x certa
- for i = #data[p].x,1,-1 do
- if tfm.get.room.playerList[p].x > data[p].x[i] - 30 and tfm.get.room.playerList[p].x < data[p].x[i] + 30 then
- return true -- Retorna true
- end
- end
- end
- function remove(p) -- Remove dados da data do jogador
- for i = #data[p].x,1,-1 do
- table.remove(data[p].x,i)
- table.remove(data[p].y,i)
- end
- end
- function add(p) -- Adiciona dados na data do jogador
- for i = #x,1,-1 do
- table.insert(data[p].x,x[i])
- table.insert(data[p].y,y[i])
- end
- end
- function eventNewGame() -- Quando uma nova partida inicia-se...
- for i = #x,1,-1 do
- table.remove(x,i) -- Remove tudo da tabela x
- table.remove(y,i) -- Remove tudo da tabela y
- end
- for xml in tfm.get.room.xmlMapInfo.xml:gmatch("<O[^/]+/>") do -- Pega as partes dentro <O /> no xml
- if xml:match('C="(%d+)"') == "6" then -- Verifica se o objeto é uma bola
- table.insert(x,tonumber(xml:match('X="(%d+)"'))) -- Inseri na tabela o x
- table.insert(y,tonumber(xml:match('Y="(%d+)"'))) -- Inseri na tabela o y
- end
- end
- for i in pairs(tfm.get.room.playerList) do
- giveData(i)
- remove(i)
- add(i)
- end
- end
- function eventLoop()
- for i in pairs(tfm.get.room.playerList) do
- if data[i] and xPosition(i) == true then
- yPostion(i)
- end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment