Fooksie

#minimake

May 25th, 2014
826
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 8.10 KB | None | 0 0
  1. left=20
  2. right=19
  3. make=false
  4. players={}
  5. eve={
  6.     None=0,
  7.     One=1,
  8.     Two=2,
  9.     Everyone=50,
  10.     Normal=0,
  11.     Strong=20,
  12.     Absurd=40,
  13.     HELP=-40,
  14.     Nothing=function()end,
  15.     Respawn=tfm.exec.respawnPlayer,
  16.     Stop=function(name)
  17.         tfm.exec.movePlayer(name, 0, 0, true, 1, 1, false)
  18.         end,
  19.     Death=function(name, x, y)
  20.         tfm.exec.killPlayer(name)
  21.         tfm.exec.addShamanObject(59, x, y)
  22.         end,
  23.     Victory=function(name)
  24.         tfm.exec.giveCheese(name)
  25.         tfm.exec.playerVictory(name)
  26.         end,
  27.     Fly=function(name)
  28.         if os.time()-players[name].fly>500 then
  29.             players[name].fly=os.time()
  30.             tfm.exec.movePlayer(name, 0, 0, true, 0, -60, false)
  31.             end
  32.         end,
  33.     Warp=function(name, x, y, xd, yd)
  34.         tfm.exec.movePlayer(name, 40*xd, 40*yd, true)
  35.         tfm.exec.displayParticle(36, x, y, 0, 0, 0, 0)
  36.         end,
  37.     Cannon=function(name, x, y)
  38.         if os.time()-players[name].shoot>1000 then
  39.             players[name].shoot=os.time()
  40.             tfm.exec.addShamanObject(players[name].facing, x, y+10)
  41.             end
  42.         end,
  43.     Conjure=function(name, x, y, xd, yd)
  44.         tfm.exec.addConjuration(x/10+xd*2, y/10+yd*2, 5000)
  45.         end,
  46.     Explosion=function(name)
  47.         local p=tfm.get.room.playerList[name]
  48.         tfm.exec.explosion(p.x, p.y, 120, 120)
  49.         local xf, yf
  50.         for i=1, 12 do
  51.             xf, yf=math.cos(math.pi*2*i/12), math.sin(math.pi*2*i/12)
  52.             tfm.exec.displayParticle(4, p.x+xf*10, p.y+yf*10, xf*2, yf*2, 0, 0)
  53.             end
  54.         for i=1, 8 do
  55.             xf, yf=math.cos(math.pi*2*i/8), math.sin(math.pi*2*i/8)
  56.             tfm.exec.displayParticle(11, p.x+xf*10, p.y+yf*10, xf, yf, 0, 0)
  57.             end
  58.         end,
  59.     KillEveryone=function(name)
  60.         for _name, player in pairs(tfm.get.room.playerList) do
  61.             if _name~=name then
  62.                 tfm.exec.killPlayer(_name)
  63.                 end
  64.             end
  65.         end,
  66.     Walls=function()
  67.         if bx==0 then
  68.             for i=0, 79 do
  69.                 tfm.exec.addConjuration(i, 0, 36000)
  70.                 tfm.exec.addConjuration(i, 39, 36000)
  71.                 end
  72.             for i=0, 39 do
  73.                 tfm.exec.addConjuration(0, i, 36000)
  74.                 tfm.exec.addConjuration(79, i, 36000)
  75.                 end
  76.             bx=1
  77.             end
  78.         end,
  79.     Platforms=function()
  80.         if bx==0 then
  81.             bx=5
  82.             local x, y=math.random(72), math.random(30)
  83.             for i=1, 8 do
  84.                 tfm.exec.addConjuration(x+i, y, 5000)
  85.                 end
  86.         else
  87.             bx=bx-1
  88.             end
  89.         end,
  90.     Snake=function()
  91.         for i=1, 5 do
  92.             bsnake=bsnake+math.random(-10, 10)/20
  93.             bx=bx+math.cos(bsnake)
  94.             by=by+math.sin(bsnake)
  95.             if bx>80 then bx=0
  96.             elseif bx<0 then bx=80 end
  97.             if by>40 then by=0
  98.             elseif by<0 then by=40 end
  99.             tfm.exec.addConjuration(bx, by, 5000)
  100.             end
  101.         end,
  102.     MouseTrap=function()
  103.         if bx==0 then
  104.             bx=10
  105.             local x, y
  106.             for name, player in pairs(tfm.get.room.playerList) do
  107.                 x, y=player.x/10, player.y/10
  108.                 for i=-3, 3 do
  109.                     tfm.exec.addConjuration(x+i, y-3, 2000)
  110.                     tfm.exec.addConjuration(x+i, y+3, 2000)
  111.                     tfm.exec.addConjuration(x-3, y+i, 2000)
  112.                     tfm.exec.addConjuration(x+3, y+i, 2000)
  113.                     end
  114.                 end
  115.         else
  116.             bx=bx-1
  117.             end
  118.         end,
  119.     HeavyRain=function()
  120.         bx=bx+8
  121.         if bx==80 then
  122.             bx=0
  123.             by=by+8
  124.             if by==80 then
  125.                 by=0
  126.                 end
  127.             end
  128.         for i=1, 8 do
  129.             tfm.exec.addConjuration(bx+i, by+i, 6000)
  130.             end
  131.         end
  132.     }
  133. active={}
  134. opts={
  135.     {   "Controls",
  136.         "When a player presses...",
  137.         {14, 80, 200, 280},
  138.         {   "UP",
  139.             {20, 126, 86, 100},
  140.             {"Nothing", "Stop", "Death", "Fly", "Warp", "Cannon", "Conjure"}
  141.             },
  142.         {   "DOWN",
  143.             {122, 126, 86, 100},
  144.             {"Nothing", "Stop", "Death", "Fly", "Warp", "Cannon", "Conjure"}
  145.             },
  146.         {   "LEFT",
  147.             {20, 240, 86, 100},
  148.             {"Nothing", "Stop", "Death", "Fly", "Warp", "Cannon", "Conjure"}
  149.             },
  150.         {   "RIGHT",
  151.             {122, 240, 86, 100},
  152.             {"Nothing", "Stop", "Death", "Fly", "Warp", "Cannon", "Conjure"}
  153.             }
  154.         },
  155.     {   "Events",
  156.         "When a player does...",
  157.         {228, 80, 200, 280},
  158.         {   "DEATH",
  159.             {234, 126, 86, 100},
  160.             {"Nothing", "Respawn", "Explosion"}
  161.             },
  162.         {   "RESPAWN",
  163.             {336, 126, 86, 100},
  164.             {"Nothing"}
  165.             },
  166.         {   "CHEESE",
  167.             {234, 240, 86, 100},
  168.             {"Nothing", "Death", "Explosion", "KillEveryone"}
  169.             },
  170.         {   "HOLE",
  171.             {336, 240, 86, 100},
  172.             {"Nothing", "Respawn", "Explosion", "KillEveryone"}
  173.             }
  174.         },
  175.     {   "Whatever",
  176.         "There should be...",
  177.         {442, 80, 200, 280},
  178.         {   "SHAMANS",
  179.             {448, 126, 86, 100},
  180.             {"None", "One", "Two", "Everyone"}
  181.             },
  182.         {   "GRAVITY",
  183.             {550, 126, 86, 100},
  184.             {"Normal", "Strong", "Absurd", "HELP"}
  185.             },
  186.         {   "BLOCKS",
  187.             {448, 240, 86, 100},
  188.             {"Nothing", "Walls", "Platforms", "Snake", "MouseTrap", "HeavyRain"}
  189.             },
  190.         }
  191.     }
  192. function openMenu()
  193.     local p, k, e
  194.     for i=1, #opts do
  195.         p=opts[i][3]
  196.         ui.addTextArea(i*100,
  197.             "<p align='center'><font size='16'><b>"..opts[i][1].."</b></font>\n"..opts[i][2].."</p>",
  198.             nil, p[1], p[2], p[3], p[4], 0x0E242D, 0x000001, 0.8)
  199.         for j=4, #opts[i] do
  200.             p=opts[i][j]
  201.             p[4]={}
  202.             active[p[1]]=eve.Nothing
  203.             ui.addTextArea(i*100+j*10, p[1],
  204.                 nil, p[2][1], p[2][2], p[2][3], p[2][4], 0x0E242D, 0x000001, 0.8)
  205.             for k=1, math.min(#p[3], 5) do
  206.                 e=p[3][1]
  207.                 while p[4][e] do
  208.                     e=p[3][math.random(#p[3])]
  209.                     end
  210.                 p[4][e]=0
  211.                 end
  212.             k=0
  213.             for key, val in pairs(p[4]) do
  214.                 k=k+1
  215.                 ui.addTextArea(i*100+j*10+k,
  216.                     "<a href='event:vote "..i.." "..j.." "..key.."'>(0) "..key.."</a>",
  217.                     nil, p[2][1], 4+p[2][2]+k*14, nil, nil, 0, 0, 0)
  218.                 end
  219.             end
  220.         end
  221.     end
  222. function tallyVotes()
  223.     local top, k--ek
  224.     for i=1, #opts do
  225.         ui.removeTextArea(i*100)
  226.         for j=4, #opts[i] do
  227.             k=0
  228.             top=-1
  229.             ui.removeTextArea(i*100+j*10)
  230.             for key, val in pairs(opts[i][j][4]) do
  231.                 k=k+1
  232.                 ui.removeTextArea(i*100+j*10+k)
  233.                 if val>top then
  234.                     top=val
  235.                     active[opts[i][j][1]]=eve[key]
  236.                     end
  237.                 end
  238.             end
  239.         end
  240.     end
  241. function eventTextAreaCallback(id, name, callback)
  242.     local args={}
  243.     for arg in callback:gmatch("[^%s]+") do
  244.         table.insert(args, tonumber(arg) or arg)
  245.         end
  246.     if args[1]=="vote" then
  247.         local on=opts[args[2]][args[3]][4]
  248.         for i, votedOn in ipairs(players[name].votedOn) do
  249.             if votedOn==on then
  250.                 return
  251.                 end
  252.             end
  253.         table.insert(players[name].votedOn, on)
  254.         on[args[4]]=on[args[4]]+1
  255.         ui.updateTextArea(id,
  256.             "<a href='event: vote "..args[2].." "..args[3].." "..args[4].."'>("
  257.             ..on[args[4]]..") "..args[4].."</a>")
  258.         end
  259.     end
  260. function eventLoop(time, remaining)
  261.     if not make and time>3000 then
  262.         active.BLOCKS()
  263.         if active.GRAVITY~=0 then
  264.             for name, player in pairs(tfm.get.room.playerList) do
  265.                 tfm.exec.movePlayer(name, 0, 0, true, 0, active.GRAVITY, true)
  266.                 end
  267.             end
  268.         end
  269.     if remaining<500 then
  270.         if not make then
  271.             make=true
  272.             openMenu()
  273.             tfm.exec.setGameTime(10)
  274.         else
  275.             make=false
  276.             tallyVotes()
  277.             tfm.exec.newGame(math.random(100)-1)
  278.             end
  279.         end
  280.     end
  281. function eventNewGame()
  282.     bx=0
  283.     by=0
  284.     bsnake=0
  285.     tfm.exec.setGameTime(30)
  286.     local players=tfm.get.room.playerList
  287.     if active.SHAMANS==50 then
  288.         for name, player in pairs(players) do
  289.             tfm.exec.setShaman(name)
  290.             end
  291.     elseif active.SHAMANS>0 then
  292.         local dom, sub
  293.         for name, player in pairs(players) do
  294.             if not dom then
  295.                 dom=player
  296.             elseif not sub then
  297.                 sub=player
  298.             elseif player.score>dom.score then
  299.                 sub=dom
  300.                 dom=player
  301.                 end
  302.             end
  303.         tfm.exec.setShaman(dom.playerName)
  304.         if active.SHAMANS==2 then
  305.             tfm.exec.setShaman(sub.playerName)
  306.             end
  307.         end
  308.     end
  309. function eventNewPlayer(name)
  310.     players[name]={
  311.         fly=0,
  312.         shoot=0,
  313.         votedOn={}
  314.         }
  315.     for i, key in ipairs({37, 38, 39, 40, 68, 81, 83, 90}) do
  316.         tfm.exec.bindKeyboard(name, key, true, true)
  317.         end
  318.     end
  319. function eventPlayerGetCheese(name)
  320.     active.CHEESE(name)
  321.     end
  322. function eventPlayerWon(name)
  323.     active.HOLE(name)
  324.     end
  325. function eventPlayerDied(name)
  326.     active.DEATH(name)
  327.     end
  328. function eventKeyboard(name, key, down, x, y)
  329.     if not make and not tfm.get.room.playerList[name].isDead then
  330.         if key==37 or key==81 then
  331.             players[name].facing=left
  332.             active.LEFT(name, x, y, -1, 0)
  333.         elseif key==39 or key==68 then
  334.             players[name].facing=right
  335.             active.RIGHT(name, x, y, 1, 0)
  336.         elseif key==38 or key==90 then
  337.             active.UP(name, x, y, 0, -1)
  338.         elseif key==40 or key==83 then
  339.             active.DOWN(name, x, y, 0, 1)
  340.             end
  341.         end
  342.     end
  343. for name, player in pairs(tfm.get.room.playerList) do
  344.     eventNewPlayer(name)
  345.     end
  346. tfm.exec.disableAutoNewGame(true)
  347. tfm.exec.disableAutoShaman(true)
  348. eventLoop(0, 0)
Advertisement
Add Comment
Please, Sign In to add comment