SHOW:
|
|
- or go back to the newest paste.
1 | tfm.exec.disableAutoNewGame(true) | |
2 | - | tfm.exec.bindKeyboard(name,32,true,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} | |
6 | ||
7 | function eventNewPlayer(name) | |
8 | for i,key in ipairs({32,40,83}) do | |
9 | tfm.exec.bindKeyboard(name,key,true,true) | |
10 | - | if key==32 then |
10 | + | |
11 | - | tfm.exec.movePlayer(name,0,0,true,0,-50,false) |
11 | + | players[name]={ |
12 | timestamp=os.time(), | |
13 | - | end |
13 | + | offsets={x=2, y=10} |
14 | } | |
15 | end | |
16 | ||
17 | function eventKeyboard(name,key,down,x,y) | |
18 | if (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 | elseif key==32 then | |
30 | tfm.exec.movePlayer(name,0,0,true,0,-50,false) | |
31 | end | |
32 | end | |
33 | ||
34 | function eventChatCommand(name,command) | |
35 | local arg={} | |
36 | for argument in command:gmatch("[^%s]+") do | |
37 | table.insert(arg,argument) | |
38 | end | |
39 | if arg[1]=="off" then | |
40 | if tonumber(arg[2]) and tonumber(arg[3]) then | |
41 | players[name].offsets.x=tonumber(arg[2]) | |
42 | players[name].offsets.y=tonumber(arg[3]) | |
43 | else | |
44 | players[name].offsets.x=2 | |
45 | players[name].offsets.y=10 | |
46 | end | |
47 | print("Offsets changed to X:"..players[name].offsets.x.." Y:"..players[name].offsets.y,name) | |
48 | end | |
49 | end | |
50 | ||
51 | function eventNewGame() | |
52 | started=false | |
53 | end | |
54 | ||
55 | function eventLoop(time,remaining) | |
56 | if time >= 3000 and not started then | |
57 | started=true | |
58 | end | |
59 | if remaining<=0 then | |
60 | tfm.exec.newGame(maps[math.random(#maps)]) | |
61 | end | |
62 | for i,cannon in ipairs(toDespawn) do | |
63 | if cannon[1] <= os.time()-3000 then | |
64 | tfm.exec.removeObject(cannon[2]) | |
65 | table.remove(toDespawn,i) | |
66 | end | |
67 | end | |
68 | end | |
69 | ||
70 | function eventPlayerDied(name) | |
71 | local i=0 | |
72 | local n | |
73 | for pname,player in pairs(tfm.get.room.playerList) do | |
74 | if not player.isDead then | |
75 | i=i+1 | |
76 | n=pname | |
77 | end | |
78 | end | |
79 | if i==0 then | |
80 | tfm.exec.newGame(maps[math.random(#maps)]) | |
81 | elseif i==1 then | |
82 | tfm.exec.giveCheese(n) | |
83 | tfm.exec.playerVictory(n) | |
84 | tfm.exec.setGameTime(5) | |
85 | end | |
86 | end | |
87 | ||
88 | for name,player in pairs(tfm.get.room.playerList) do | |
89 | eventNewPlayer(name) | |
90 | end | |
91 | ||
92 | tfm.exec.newGame(maps[math.random(#maps)]) |