Thetroz

#Free for all

Dec 24th, 2013
164
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 3.38 KB | None | 0 0
  1. tfm.exec.disableAutoNewGame(true)
  2. tfm.exec.disableAutoShaman(true)
  3. players={}
  4. toDespawn={}
  5. maps={521833,401421,541917,541928,541936,541943,527935,559634,559644,888052,878047,885641,770600,770656,772172,891472,589736,589800,589708,900012,901062,754380,901337,901411,907870,910078,1190467,1252043,1124380,1016258,1252299,1255902,1256808,986790,1285380,1271249,1255944,1255983,1085344,1273114,1276664,1279258,1286824,1280135,1280342,1284861,1287556,1057753,1196679,1288489,1292983,1298164,1298521,1293189,1296949,1308378,1311136,1314419,1314982,1318248,1312411,1312589,1312845,1312933,1313969,1338762,1339474,1349878,1297154,644588,1351237,1354040,1354375,1362386,1283234,1370578,1306592,1360889,1362753,1408124,1407949,1407849,1343986,1408028,1441370,1443416,1389255,1427349,1450527,1424739,869836,1459902,1392993,1426457,1542824,1533474,1561467,1563534,1566991,1587241,1416119,1596270,1601580,1525751,1582146,1558167,1420943,1466487,1642575,1648013,1646094,1393097,1643446,1545219,1583484,1613092,1627981,1633374,1633277,1633251,1585138,1624034,1616785,1625916,1667582,1666996,1675013,1675316,1531316,1665413,1681719,1699880,1688696,623770,1727243,1531329,1683915,1689533,1738601,3756146,912118,3326933,3722005,3566478,1456622,1357994,1985670,1884075,1708065,1700322,2124484,3699046,2965313,4057963,4019126,3335202,2050466,000000000000000000}
  6.  
  7. function eventNewPlayer(name)
  8.     for i,key in ipairs({32,40,83}) do
  9.         tfm.exec.bindKeyboard(name,key,true,true)
  10.     end
  11.     players[name]={
  12.         timestamp=os.time(),
  13.         offsets={x=2, y=10}
  14.     }
  15. end
  16.  
  17. function eventKeyboard(name,key,down,x,y)
  18.     if (key==32 or key==40 or key==83) and not tfm.get.room.playerList[name].isDead and started then
  19.         if players[name].timestamp < os.time()-1000 then
  20.             local id
  21.             if tfm.get.room.playerList[name].isFacingRight then
  22.                 id=tfm.exec.addShamanObject(19,x+players[name].offsets.x,y+players[name].offsets.y)
  23.             else
  24.                 id=tfm.exec.addShamanObject(20,x+players[name].offsets.x,y+players[name].offsets.y)
  25.             end
  26.             players[name].timestamp=os.time()
  27.             table.insert(toDespawn,{os.time(),id})
  28.         end
  29.     end
  30. end
  31.  
  32. function eventChatCommand(name,command)
  33.     local arg={}
  34.     for argument in command:gmatch("[^%s]+") do
  35.         table.insert(arg,argument)
  36.     end
  37.     if arg[1]=="off" then
  38.         if tonumber(arg[2]) and tonumber(arg[3]) then
  39.             players[name].offsets.x=tonumber(arg[2])
  40.             players[name].offsets.y=tonumber(arg[3])
  41.         else
  42.             players[name].offsets.x=2
  43.             players[name].offsets.y=10
  44.         end
  45.         tfm.exec.chatMessage("Offsets changed to X:"..players[name].offsets.x.." Y:"..players[name].offsets.y,name)
  46.     end
  47. end
  48.  
  49. function eventNewGame()
  50.     started=false
  51. end
  52.  
  53. function eventLoop(time,remaining)
  54.     if time >= 3000 and not started then
  55.         started=true
  56.     end
  57.     if remaining<=0 then
  58.         tfm.exec.newGame(maps[math.random(#maps)])
  59.     end
  60.     for i,cannon in ipairs(toDespawn) do
  61.         if cannon[1] <= os.time()-3000 then
  62.             tfm.exec.removeObject(cannon[2])
  63.             table.remove(toDespawn,i)
  64.         end
  65.     end
  66. end
  67.  
  68. function eventPlayerDied(name)
  69.     local i=0
  70.     local n
  71.     for pname,player in pairs(tfm.get.room.playerList) do
  72.         if not player.isDead then
  73.             i=i+1
  74.             n=pname
  75.         end
  76.     end
  77.     if i==0 then
  78.         tfm.exec.newGame(maps[math.random(#maps)])
  79.     elseif i==1 then
  80.         tfm.exec.giveCheese(n)
  81.         tfm.exec.playerVictory(n)
  82.         tfm.exec.setGameTime(5)
  83.     end
  84. end
  85.  
  86. for name,player in pairs(tfm.get.room.playerList) do
  87.     eventNewPlayer(name)
  88. end
  89.  
  90. tfm.exec.newGame(maps[math.random(#maps)])
Add Comment
Please, Sign In to add comment