Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- left=20
- right=19
- make=false
- players={}
- eve={
- None=0,
- One=1,
- Two=2,
- Everyone=50,
- Normal=0,
- Strong=20,
- Absurd=40,
- HELP=-40,
- Nothing=function()end,
- Respawn=tfm.exec.respawnPlayer,
- Stop=function(name)
- tfm.exec.movePlayer(name, 0, 0, true, 1, 1, false)
- end,
- Death=function(name, x, y)
- tfm.exec.killPlayer(name)
- tfm.exec.addShamanObject(59, x, y)
- end,
- Victory=function(name)
- tfm.exec.giveCheese(name)
- tfm.exec.playerVictory(name)
- end,
- Fly=function(name)
- if os.time()-players[name].fly>500 then
- players[name].fly=os.time()
- tfm.exec.movePlayer(name, 0, 0, true, 0, -60, false)
- end
- end,
- Warp=function(name, x, y, xd, yd)
- tfm.exec.movePlayer(name, 40*xd, 40*yd, true)
- tfm.exec.displayParticle(36, x, y, 0, 0, 0, 0)
- end,
- Cannon=function(name, x, y)
- if os.time()-players[name].shoot>1000 then
- players[name].shoot=os.time()
- tfm.exec.addShamanObject(players[name].facing, x, y+10)
- end
- end,
- Conjure=function(name, x, y, xd, yd)
- tfm.exec.addConjuration(x/10+xd*2, y/10+yd*2, 5000)
- end,
- Explosion=function(name)
- local p=tfm.get.room.playerList[name]
- tfm.exec.explosion(p.x, p.y, 120, 120)
- local xf, yf
- for i=1, 12 do
- xf, yf=math.cos(math.pi*2*i/12), math.sin(math.pi*2*i/12)
- tfm.exec.displayParticle(4, p.x+xf*10, p.y+yf*10, xf*2, yf*2, 0, 0)
- end
- for i=1, 8 do
- xf, yf=math.cos(math.pi*2*i/8), math.sin(math.pi*2*i/8)
- tfm.exec.displayParticle(11, p.x+xf*10, p.y+yf*10, xf, yf, 0, 0)
- end
- end,
- KillEveryone=function(name)
- for _name, player in pairs(tfm.get.room.playerList) do
- if _name~=name then
- tfm.exec.killPlayer(_name)
- end
- end
- end,
- Walls=function()
- if bx==0 then
- for i=0, 79 do
- tfm.exec.addConjuration(i, 0, 36000)
- tfm.exec.addConjuration(i, 39, 36000)
- end
- for i=0, 39 do
- tfm.exec.addConjuration(0, i, 36000)
- tfm.exec.addConjuration(79, i, 36000)
- end
- bx=1
- end
- end,
- Platforms=function()
- if bx==0 then
- bx=5
- local x, y=math.random(72), math.random(30)
- for i=1, 8 do
- tfm.exec.addConjuration(x+i, y, 5000)
- end
- else
- bx=bx-1
- end
- end,
- Snake=function()
- for i=1, 5 do
- bsnake=bsnake+math.random(-10, 10)/20
- bx=bx+math.cos(bsnake)
- by=by+math.sin(bsnake)
- if bx>80 then bx=0
- elseif bx<0 then bx=80 end
- if by>40 then by=0
- elseif by<0 then by=40 end
- tfm.exec.addConjuration(bx, by, 5000)
- end
- end,
- MouseTrap=function()
- if bx==0 then
- bx=10
- local x, y
- for name, player in pairs(tfm.get.room.playerList) do
- x, y=player.x/10, player.y/10
- for i=-3, 3 do
- tfm.exec.addConjuration(x+i, y-3, 2000)
- tfm.exec.addConjuration(x+i, y+3, 2000)
- tfm.exec.addConjuration(x-3, y+i, 2000)
- tfm.exec.addConjuration(x+3, y+i, 2000)
- end
- end
- else
- bx=bx-1
- end
- end,
- HeavyRain=function()
- bx=bx+8
- if bx==80 then
- bx=0
- by=by+8
- if by==80 then
- by=0
- end
- end
- for i=1, 8 do
- tfm.exec.addConjuration(bx+i, by+i, 6000)
- end
- end
- }
- active={}
- opts={
- { "Controls",
- "When a player presses...",
- {14, 80, 200, 280},
- { "UP",
- {20, 126, 86, 100},
- {"Nothing", "Stop", "Death", "Fly", "Warp", "Cannon", "Conjure"}
- },
- { "DOWN",
- {122, 126, 86, 100},
- {"Nothing", "Stop", "Death", "Fly", "Warp", "Cannon", "Conjure"}
- },
- { "LEFT",
- {20, 240, 86, 100},
- {"Nothing", "Stop", "Death", "Fly", "Warp", "Cannon", "Conjure"}
- },
- { "RIGHT",
- {122, 240, 86, 100},
- {"Nothing", "Stop", "Death", "Fly", "Warp", "Cannon", "Conjure"}
- }
- },
- { "Events",
- "When a player does...",
- {228, 80, 200, 280},
- { "DEATH",
- {234, 126, 86, 100},
- {"Nothing", "Respawn", "Explosion"}
- },
- { "RESPAWN",
- {336, 126, 86, 100},
- {"Nothing"}
- },
- { "CHEESE",
- {234, 240, 86, 100},
- {"Nothing", "Death", "Explosion", "KillEveryone"}
- },
- { "HOLE",
- {336, 240, 86, 100},
- {"Nothing", "Respawn", "Explosion", "KillEveryone"}
- }
- },
- { "Whatever",
- "There should be...",
- {442, 80, 200, 280},
- { "SHAMANS",
- {448, 126, 86, 100},
- {"None", "One", "Two", "Everyone"}
- },
- { "GRAVITY",
- {550, 126, 86, 100},
- {"Normal", "Strong", "Absurd", "HELP"}
- },
- { "BLOCKS",
- {448, 240, 86, 100},
- {"Nothing", "Walls", "Platforms", "Snake", "MouseTrap", "HeavyRain"}
- },
- }
- }
- function openMenu()
- local p, k, e
- for i=1, #opts do
- p=opts[i][3]
- ui.addTextArea(i*100,
- "<p align='center'><font size='16'><b>"..opts[i][1].."</b></font>\n"..opts[i][2].."</p>",
- nil, p[1], p[2], p[3], p[4], 0x0E242D, 0x000001, 0.8)
- for j=4, #opts[i] do
- p=opts[i][j]
- p[4]={}
- active[p[1]]=eve.Nothing
- ui.addTextArea(i*100+j*10, p[1],
- nil, p[2][1], p[2][2], p[2][3], p[2][4], 0x0E242D, 0x000001, 0.8)
- for k=1, math.min(#p[3], 5) do
- e=p[3][1]
- while p[4][e] do
- e=p[3][math.random(#p[3])]
- end
- p[4][e]=0
- end
- k=0
- for key, val in pairs(p[4]) do
- k=k+1
- ui.addTextArea(i*100+j*10+k,
- "<a href='event:vote "..i.." "..j.." "..key.."'>(0) "..key.."</a>",
- nil, p[2][1], 4+p[2][2]+k*14, nil, nil, 0, 0, 0)
- end
- end
- end
- end
- function tallyVotes()
- local top, k--ek
- for i=1, #opts do
- ui.removeTextArea(i*100)
- for j=4, #opts[i] do
- k=0
- top=-1
- ui.removeTextArea(i*100+j*10)
- for key, val in pairs(opts[i][j][4]) do
- k=k+1
- ui.removeTextArea(i*100+j*10+k)
- if val>top then
- top=val
- active[opts[i][j][1]]=eve[key]
- end
- end
- end
- end
- end
- function eventTextAreaCallback(id, name, callback)
- local args={}
- for arg in callback:gmatch("[^%s]+") do
- table.insert(args, tonumber(arg) or arg)
- end
- if args[1]=="vote" then
- local on=opts[args[2]][args[3]][4]
- for i, votedOn in ipairs(players[name].votedOn) do
- if votedOn==on then
- return
- end
- end
- table.insert(players[name].votedOn, on)
- on[args[4]]=on[args[4]]+1
- ui.updateTextArea(id,
- "<a href='event: vote "..args[2].." "..args[3].." "..args[4].."'>("
- ..on[args[4]]..") "..args[4].."</a>")
- end
- end
- function eventLoop(time, remaining)
- if not make and time>3000 then
- active.BLOCKS()
- if active.GRAVITY~=0 then
- for name, player in pairs(tfm.get.room.playerList) do
- tfm.exec.movePlayer(name, 0, 0, true, 0, active.GRAVITY, true)
- end
- end
- end
- if remaining<500 then
- if not make then
- make=true
- openMenu()
- tfm.exec.setGameTime(10)
- else
- make=false
- tallyVotes()
- tfm.exec.newGame(math.random(100)-1)
- end
- end
- end
- function eventNewGame()
- bx=0
- by=0
- bsnake=0
- tfm.exec.setGameTime(30)
- local players=tfm.get.room.playerList
- if active.SHAMANS==50 then
- for name, player in pairs(players) do
- tfm.exec.setShaman(name)
- end
- elseif active.SHAMANS>0 then
- local dom, sub
- for name, player in pairs(players) do
- if not dom then
- dom=player
- elseif not sub then
- sub=player
- elseif player.score>dom.score then
- sub=dom
- dom=player
- end
- end
- tfm.exec.setShaman(dom.playerName)
- if active.SHAMANS==2 then
- tfm.exec.setShaman(sub.playerName)
- end
- end
- end
- function eventNewPlayer(name)
- players[name]={
- fly=0,
- shoot=0,
- votedOn={}
- }
- for i, key in ipairs({37, 38, 39, 40, 68, 81, 83, 90}) do
- tfm.exec.bindKeyboard(name, key, true, true)
- end
- end
- function eventPlayerGetCheese(name)
- active.CHEESE(name)
- end
- function eventPlayerWon(name)
- active.HOLE(name)
- end
- function eventPlayerDied(name)
- active.DEATH(name)
- end
- function eventKeyboard(name, key, down, x, y)
- if not make and not tfm.get.room.playerList[name].isDead then
- if key==37 or key==81 then
- players[name].facing=left
- active.LEFT(name, x, y, -1, 0)
- elseif key==39 or key==68 then
- players[name].facing=right
- active.RIGHT(name, x, y, 1, 0)
- elseif key==38 or key==90 then
- active.UP(name, x, y, 0, -1)
- elseif key==40 or key==83 then
- active.DOWN(name, x, y, 0, 1)
- end
- end
- end
- for name, player in pairs(tfm.get.room.playerList) do
- eventNewPlayer(name)
- end
- tfm.exec.disableAutoNewGame(true)
- tfm.exec.disableAutoShaman(true)
- eventLoop(0, 0)
Advertisement
Add Comment
Please, Sign In to add comment