Transformice - Teleport example

By Jordy19 on Nov 30, 2014

This Lua script is written for the Transformice.
Click another mouse and you will teleport to that mouse it's location and that mouse will teleport to your location.

-- Author: Jordynl

players = {}

function pythag(x1,y1,x2,y2,r)
    local x=x2-x1
    local y=y2-y1
    local r=r+r
    return x*x+y*y<r*r
end

function eventNewPlayer(name)
    players[name] = {
        spawned = true,
    }
    system.bindMouse(name, true)
end

function eventMouse(playerName, x, y)
    if players[playerName].spawned then
        for name, player in pairs(tfm.get.room.playerList) do
            if pythag(x, y, player.x, player.y, 25) and playerName ~= name then
                local playerData = tfm.get.room.playerList[playerName]
                tfm.exec.movePlayer(name, playerData.x, playerData.y)
                tfm.exec.displayParticle(36,playerData.x,playerData.y,0,0,0,0,nil)
                tfm.exec.displayParticle(36,player.x,player.y,0,0,0,0,nil)
                tfm.exec.movePlayer(playerName, player.x, player.y)
            end
        end
    end
end

for k,v in pairs({}) do
    tfm.exec["disable"..v](true)
end

for name, player in pairs(tfm.get.room.playerList) do
    eventNewPlayer(name)    
end

Comments

Sign in to comment.
Hawkee   -  Dec 01, 2014

I'd never heard of Transformice before seeing this, but it's refreshing to see something new. Might be a good idea to include that in your title so this can be found more easily.

 Respond  
Are you sure you want to unfollow this person?
Are you sure you want to delete this?
Click "Unsubscribe" to stop receiving notices pertaining to this post.
Click "Subscribe" to resume notices pertaining to this post.