Advertisement
Guest User

v0.2

a guest
Feb 5th, 2015
258
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.42 KB | None | 0 0
  1. --#transform
  2. Box={type=12, width=30, height=10, foreground=true, friction=0.3, restitution=0.2, angle=0, color="0x6a7495", miceCollision=true, groundCollision=false}
  3. id={}
  4. obj={}
  5. x={}
  6. y={}
  7. checkCoords={}
  8. wait={}
  9. function updateMap()
  10. tfm.exec.addPhysicObject(1, 396, -166, Box)
  11. tfm.exec.addPhysicObject(2, 396, -205, Box)
  12. Box["angle"]=90
  13. tfm.exec.addPhysicObject(3, 376, -185, Box)
  14. tfm.exec.addPhysicObject(4, 416, -186, Box)
  15. Box["angle"]=0
  16. Box["width"]=794
  17. Box["height"]=150
  18. tfm.exec.addPhysicObject(5, 420, -229, Box)
  19. Box["width"]=30
  20. Box["height"]=10
  21. tfm.exec.setUIMapName("#<R>Transform<J>ice!<N>")
  22. end
  23.  
  24. function hide(playerName)
  25. x[playerName]=tfm.get.room.playerList[playerName].x
  26. y[playerName]=tfm.get.room.playerList[playerName].y
  27. tfm.exec.movePlayer(playerName, 395, -185)
  28. obj[playerName]=tfm.exec.addShamanObject(54, x[playerName], y[playerName], 0, 0, 0, false)
  29. checkCoords[playerName]=true
  30. end
  31.  
  32. function eventKeyboard(playerName, keyCode, down, xPosition, yPosition)
  33.     if keyCode==32 and xPosition~=0 and yPosition~=0 and checkCoords[playerName]~=true and os.time() - wait[playerName] >= 1000 then
  34.         hide(playerName)
  35.         wait[playerName]=os.time()
  36.     elseif keyCode==32 and xPosition~=0 and yPosition~=0 and checkCoords[playerName]==true and os.time() - wait[playerName] >= 1000 then
  37.         tfm.exec.removeObject(obj[playerName])
  38.         tfm.exec.movePlayer(playerName, x[playerName], y[playerName])
  39.         x[playerName]=nil
  40.         y[playerName]=nil
  41.         checkCoords[playerName]=nil
  42.         obj[playerName]=nil
  43.         wait[playerName]=os.time()
  44.     end
  45. end
  46. function eventNewPlayer(playerName)
  47. tfm.exec.bindKeyboard(playerName, 32, true, true)
  48.         if id[playerName]==nil then
  49.         table.insert(id,playerName)
  50.         id[playerName]=table.IndexOf(id, playerName)
  51.  
  52.     else
  53.  
  54.     end
  55. end
  56. function eventNewGame()
  57.     for name, p in pairs(tfm.get.room.playerList) do
  58.         wait[name]=0
  59.         x[name]=nil
  60.         y[name]=nil
  61.         checkCoords[name]=nil
  62.         obj[name]=nil
  63.     end
  64.         updateMap()
  65. end
  66. function eventLoop(a, timleft)
  67.     for name, p in pairs(tfm.get.room.playerList) do
  68.         if checkCoords[name]==true then
  69.             x[name] = tfm.get.room.objectList[obj[name]].x
  70.             y[name] = tfm.get.room.objectList[obj[name]].y
  71.             --print(x[name].." "..y[name])
  72.         end
  73.     end
  74. end
  75.  
  76. table.IndexOf=function(t, value)
  77.     for i, v in ipairs(t) do
  78.         if v==value then
  79.             return i
  80.         end
  81.     end
  82. return false
  83. end
  84. for name, p in pairs(tfm.get.room.playerList) do
  85.     eventNewPlayer(name)
  86. end
  87. tfm.exec.newGame()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement