Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --#transform
- Box={type=12, width=30, height=10, foreground=true, friction=0.3, restitution=0.2, angle=0, color="0x6a7495", miceCollision=true, groundCollision=false}
- id={}
- obj={}
- x={}
- y={}
- checkCoords={}
- wait={}
- function updateMap()
- tfm.exec.addPhysicObject(1, 396, -166, Box)
- tfm.exec.addPhysicObject(2, 396, -205, Box)
- Box["angle"]=90
- tfm.exec.addPhysicObject(3, 376, -185, Box)
- tfm.exec.addPhysicObject(4, 416, -186, Box)
- Box["angle"]=0
- Box["width"]=794
- Box["height"]=150
- tfm.exec.addPhysicObject(5, 420, -229, Box)
- Box["width"]=30
- Box["height"]=10
- tfm.exec.setUIMapName("#<R>Transform<J>ice!<N>")
- end
- function hide(playerName)
- x[playerName]=tfm.get.room.playerList[playerName].x
- y[playerName]=tfm.get.room.playerList[playerName].y
- tfm.exec.movePlayer(playerName, 395, -185)
- obj[playerName]=tfm.exec.addShamanObject(54, x[playerName], y[playerName], 0, 0, 0, false)
- checkCoords[playerName]=true
- end
- function eventKeyboard(playerName, keyCode, down, xPosition, yPosition)
- if keyCode==32 and xPosition~=0 and yPosition~=0 and checkCoords[playerName]~=true and os.time() - wait[playerName] >= 1000 then
- hide(playerName)
- wait[playerName]=os.time()
- elseif keyCode==32 and xPosition~=0 and yPosition~=0 and checkCoords[playerName]==true and os.time() - wait[playerName] >= 1000 then
- tfm.exec.removeObject(obj[playerName])
- tfm.exec.movePlayer(playerName, x[playerName], y[playerName])
- x[playerName]=nil
- y[playerName]=nil
- checkCoords[playerName]=nil
- obj[playerName]=nil
- wait[playerName]=os.time()
- end
- end
- function eventNewPlayer(playerName)
- tfm.exec.bindKeyboard(playerName, 32, true, true)
- if id[playerName]==nil then
- table.insert(id,playerName)
- id[playerName]=table.IndexOf(id, playerName)
- else
- end
- end
- function eventNewGame()
- for name, p in pairs(tfm.get.room.playerList) do
- wait[name]=0
- x[name]=nil
- y[name]=nil
- checkCoords[name]=nil
- obj[name]=nil
- end
- updateMap()
- end
- function eventLoop(a, timleft)
- for name, p in pairs(tfm.get.room.playerList) do
- if checkCoords[name]==true then
- x[name] = tfm.get.room.objectList[obj[name]].x
- y[name] = tfm.get.room.objectList[obj[name]].y
- --print(x[name].." "..y[name])
- end
- end
- end
- table.IndexOf=function(t, value)
- for i, v in ipairs(t) do
- if v==value then
- return i
- end
- end
- return false
- end
- for name, p in pairs(tfm.get.room.playerList) do
- eventNewPlayer(name)
- end
- tfm.exec.newGame()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement