Advertisement
Guest User

transformice v o.1

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