Advertisement
BennyNovice

Cage In The House

Aug 22nd, 2014
752
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.94 KB | None | 0 0
  1. function eventNewPlayer(name)
  2.     for i,key in ipairs({40,83}) do
  3.     tfm.exec.bindKeyboard(name,key,true,true)
  4.     end
  5. end
  6.  
  7. for name,player in pairs(tfm.get.room.playerList) do
  8.     eventNewPlayer(name)
  9. end
  10.  
  11. downx=0
  12. downy=0
  13. leftx=0
  14. lefty=0
  15. rightx=0
  16. righty=0
  17. upx=0
  18. upy=0
  19.  
  20. bodyDef = {
  21.     type = 0,
  22.     width = 60,
  23.     height = 10,
  24.     foreground = false,
  25.     friction = 0.3,
  26.     restitution = 0.2,
  27.     angle = 0,
  28.     miceCollision = true,
  29.     groundCollision = false,
  30.     dynamic = false,
  31.     fixedRotation = true,
  32.     mass = 0,
  33.     linearDamping = 0,
  34.     angularDamping = 0
  35. }
  36.  
  37. function eventKeyboard(name,key,down,x,y)
  38.     -- up and down ground
  39.     tfm.exec.removePhysicObject(1)
  40.     bodyDef.type=0
  41.     bodyDef.width=60
  42.     bodyDef.height=10
  43.     bodyDef.miceCollision = true
  44.     test = tfm.exec.addPhysicObject(1, x, y+20, bodyDef)
  45.     downx=x
  46.     downy=y+20
  47.     tfm.exec.removePhysicObject(4)
  48.     test = tfm.exec.addPhysicObject(4, x, y-30, bodyDef)
  49.     upx=x
  50.     upy=y-30
  51.    
  52.     -- left and right ground
  53.     tfm.exec.removePhysicObject(2)
  54.     bodyDef.type=0
  55.     bodyDef.width=10
  56.     bodyDef.height=60
  57.     bodyDef.miceCollision = true
  58.     test = tfm.exec.addPhysicObject(2, x-25, y-5, bodyDef)
  59.     leftx=x-25
  60.     lefty=y-5
  61.     tfm.exec.removePhysicObject(3)
  62.     test = tfm.exec.addPhysicObject(3, x+25, y-5, bodyDef)
  63.     rightx=x+25
  64.     righty=y-5
  65.    
  66.    
  67. end
  68.  
  69. function eventEmotePlayed(playerName,emote)
  70.     if emote==3 then
  71.         -- up and down ground
  72.         tfm.exec.removePhysicObject(1)
  73.         bodyDef.type=8
  74.         bodyDef.width=60
  75.         bodyDef.height=10
  76.         bodyDef.miceCollision = false
  77.         test = tfm.exec.addPhysicObject(1, downx, downy, bodyDef)
  78.         tfm.exec.removePhysicObject(4)
  79.         test = tfm.exec.addPhysicObject(4, upx, upy, bodyDef)
  80.        
  81.         -- left and right ground
  82.         tfm.exec.removePhysicObject(2)
  83.         bodyDef.type=8
  84.         bodyDef.width=10
  85.         bodyDef.height=60
  86.         bodyDef.miceCollision = false
  87.         test = tfm.exec.addPhysicObject(2, leftx, lefty, bodyDef)
  88.         tfm.exec.removePhysicObject(3)
  89.         test = tfm.exec.addPhysicObject(3, rightx, righty, bodyDef)
  90.     end
  91. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement