Advertisement
Tectoon

[TFM] #Balllua

Oct 16th, 2015
195
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 40.67 KB | None | 0 0
  1. --[[    BAFFLUA MINIGAMES
  2.                 Vampire - A quick vampire survivor round, where vampires can fly.
  3.                 Dynamic Maze - A maze is made up of moving boxes, that mice have to try and maneuver around to get the cheese.
  4.                 Cheese Hunt - (You know what it is, it just doesn't seem to be doing well as its own room so making it a minigame might be good.)
  5.                 Dodge - Random items are shot from the ground upwards with a little warning, getting faster. Mice have to doge them so they don't die.
  6.                 Auto-survivor - Mice have to dodge the cannons that the shaman shoots at them (Baffbot style).
  7.                 Dive - The opposite of fly, tapping space will launch downards (think water maps).
  8.                 Shaman Fly - Whenever the shaman taps space, every mouse in the room gets launched up a little.
  9.                 Box Building - Pick up a box and place it down to build to the cheese (Baffbot style).
  10.                 Shooting Mice - Clicking on a mouse with an arrow will launch them in that direction.
  11.                 Bloon - Mice duck to get a balloon spawned which they can ride across.
  12.  
  13.                 Simon - simon says use an emote!
  14. ]]
  15.  
  16. --Prepwork
  17. debug.disableEventLog(true)
  18. tfm.exec.disableAutoNewGame(true)
  19. tfm.exec.setRoomMaxPlayers(5)
  20. admins={
  21.         "Baffler", --noob girl
  22.         "Fxie", --im a noob
  23.         "Shamousey", --im #1
  24.         "Begentle" --im also a noob
  25.         }
  26. greets={
  27.         "Hey qt *-*",
  28.         "What's shakin bacon?",
  29.         "Hey hot stuff, ready for a good time? ;)",
  30.         "Go lick a duck and call yourself Shirley.",
  31.         "OMG it's you!! kan i get your autografph?!",
  32.         "If you touch my walrus one more time, I swear to god...",
  33.         "Who are you and why are you sitting there?",
  34.         "How you doin'? ;)"
  35.         }
  36. games={
  37.         --------------------------------------------------
  38.         {       name="Balance",
  39.                 time=15,
  40.                 shaman=false,
  41.                 intro="Don't rock the boat baby!",
  42.                 maps={"@3997635"},
  43.                 loop=function(time,remaining)
  44.                         if remaining<=1000 then
  45.                                 tfm.exec.giveWinAll()
  46.                                 end
  47.                         end
  48.                 },
  49.         --------------------------------------------------
  50.         {       name="Bomb",
  51.                 time=30,
  52.                 delay=3,
  53.                 shaman=false,
  54.                 intro="Everyone is a bomb! KO the other team before they make it to your side of the map by pressing <VP>SPACE<J> to explode!",
  55.                 maps={"111"},
  56.                 prep=function()
  57.                         minigame.teams=makeTeams()
  58.                         for name,team in pairs(minigame.teams) do
  59.                                 local red=name=="red"
  60.                                 for i=1,#team,1 do
  61.                                         tfm.exec.setNameColor(team[i],red and "0xEB1D51" or "0x2F7FCC")
  62.                                         tfm.exec.movePlayer(team[i],red and 40 or 760,360,false,0,0,false)
  63.                                         end
  64.                                 end
  65.                         end,
  66.                 loop=function()
  67.                         for name,team in pairs(minigame.teams) do
  68.                                 local red=name=="red"
  69.                                 for i=1,#team,1 do
  70.                                         local x=getPlayer(team[i]).x
  71.                                         if (red and x>600) or (not red and x<200) then
  72.                                                 minigame.won=true
  73.                                                 tfm.exec.setGameTime(5)
  74.                                                 tfm.exec.chatMessage((red and "<R><b>Red" or "<BV><b>Blue").." team won thanks to "..team[i].."!</b>")
  75.                                                 for i=1,#team,1 do
  76.                                                         tfm.exec.giveWin(team[i])
  77.                                                         end
  78.                                                 end
  79.                                         end
  80.                                 end
  81.                         end,
  82.                 keys={
  83.                         SPACE=function(name,x,y)
  84.                                 tfm.exec.killPlayer(name)
  85.                                 tfm.exec.explosion(x,y,40,125,false)
  86.                                 end
  87.                         }
  88.                 },
  89.         --------------------------------------------------
  90.         {       name="Climb",
  91.                 time=60,
  92.                 shaman=false,
  93.                 intro="Reach the top of the map!",
  94.                 maps={"111"},
  95.                 prep=function()
  96.                         minigame.clouds={}
  97.                         end,
  98.                 loop=function()
  99.                         if minigame.clouds then
  100.                                 local x=math.random(50,750)
  101.                                 local y=math.random(75,300)
  102.                                 local cloud=tfm.exec.addShamanObject(57,x,y)
  103.                                 table.insert(minigame.clouds,cloud)
  104.                                 if #minigame.clouds>=20 then
  105.                                         tfm.exec.removeObject(minigame.clouds[1])
  106.                                         table.remove(minigame.clouds,1)
  107.                                         end
  108.                                 end
  109.                         for name,player in pairs(tfm.get.room.playerList) do
  110.                                 if player.y>5 and player.y<=75 then
  111.                                         tfm.exec.giveCheese(name)
  112.                                         end
  113.                                 end
  114.                         end
  115.                 },
  116.         --------------------------------------------------
  117.         {       name="Dance",
  118.                 time=60,
  119.                 delay=5,
  120.                 shaman=true,
  121.                 intro="The shaman will give you a new direction every second! Keep up!",
  122.                 maps={"@580702"},
  123.                 prep=function()
  124.                         minigame.change=0
  125.                         minigame.dance=nil
  126.                         minigame.shaman=tfm.exec.getShaman()
  127.                         minigame.players={}
  128.                         for name,player in pairs(tfm.get.room.playerList) do
  129.                                 minigame.players[name]={
  130.                                         won=false,
  131.                                         wrong=0,
  132.                                         right=0
  133.                                         }
  134.                                 end
  135.                         end,
  136.                 loop=function()
  137.                         tfm.exec.movePlayer(minigame.shaman,400,140,false,0,-1,false)
  138.                         end,
  139.                 keys={
  140.                         DOWN=function(name,x,y)
  141.                                 minigame.move(name,"DOWN",x,y)
  142.                                 end,
  143.                         LEFT=function(name,x,y)
  144.                                 minigame.move(name,"LEFT",x,y)
  145.                                 end,
  146.                         RIGHT=function(name,x,y)
  147.                                 minigame.move(name,"RIGHT",x,y)
  148.                                 end
  149.                         },
  150.                 move=function(name,direction,x,y)
  151.                         if name==minigame.shaman then
  152.                                 local timestamp=tonumber(os.time())
  153.                                 if timestamp-minigame.change>2000 then
  154.                                         minigame.change=timestamp
  155.                                         minigame.dance=direction
  156.                                         local rotate=direction=="DOWN" and 0 or direction=="LEFT" and 90 or direction=="RIGHT" and 270
  157.                                         tfm.exec.addShamanObject(0,200,140,rotate)
  158.                                         tfm.exec.addShamanObject(0,400,80,rotate)
  159.                                         tfm.exec.addShamanObject(0,600,140,rotate)
  160.                                         end
  161.                         elseif not minigame.players[name].won then
  162.                                 elseif minigame.dance==direction then
  163.                                         tfm.exec.setPlayerScore(name,1,true)
  164.                                         minigame.players[name].right=minigame.players[name].right+1
  165.                                         if minigame.players[name].right>=15 then
  166.                                                 minigame.players[name].won=true
  167.                                                 tfm.exec.chatMessage("<J><b>You got 15 right!</b> <VP>DUCK<J> to spawn a balloon!",name)
  168.                                                 end
  169.                                 else
  170.                                         minigame.players[name].wrong=minigame.players[name].wrong+1
  171.                                         if minigame.players[name].wrong<3 then
  172.                                                 tfm.exec.chatMessage("<R>Way off!",name)
  173.                                         else
  174.                                                 tfm.exec.killPlayer(name)
  175.                                                 tfm.exec.chatMessage("<R>Three strikes, you're out!",name)
  176.                                                 end
  177.                                         end
  178.                         elseif direction=="DOWN" then
  179.                                 tfm.exec.addShamanObject(28,x,y-90)
  180.                                 tfm.exec.movePlayer(name,0,-120,true,0,-1,false)
  181.                                 end
  182.                         end
  183.                 },
  184.         --------------------------------------------------
  185.         {       name="Disco",
  186.                 time=15,
  187.                 shaman=false,
  188.                 intro="<ROSE>It's <b>party</b> time!!",
  189.                 maps={"@3926952"},
  190.                 prep=function()
  191.                         minigame.party={}
  192.                         end,
  193.                 loop=function()
  194.                         for name,player in pairs(tfm.get.room.playerList) do
  195.                                 local colors={"0","4","8","C","F"}
  196.                                 local currentColor="0x"
  197.                                 for i=1,6,1 do
  198.                                         currentColor=currentColor..table.random(colors)
  199.                                         end
  200.                                 tfm.exec.setNameColor(name,currentColor)
  201.                                 if minigame.party[name] then
  202.                                         tfm.exec.setPlayerScore(name,1,true)
  203.                                         end
  204.                                 end
  205.                         end,
  206.                 emote=function(name,emote)
  207.                         minigame.party[name]=emote==0 or nil
  208.                         end
  209.                 },
  210.         --------------------------------------------------
  211.         --[[
  212.         {       name="Fallout",
  213.                 time=60,
  214.                 shaman=false,
  215.                 intro="Random objects are falling from the sky! Look out!",
  216.                 maps={0}
  217.                 },
  218.         ]]--
  219.         --------------------------------------------------
  220.         {       name="FFA",
  221.                 time=60,
  222.                 delay=3,
  223.                 shaman=false,
  224.                 intro="You can shoot cannons by <VP>ducking<J>! Last mouse standing wins!",
  225.                 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,892660,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},
  226.                 prep=function()
  227.                         minigame.lava=nil
  228.                         minigame.players={}
  229.                         for name,player in pairs(tfm.get.room.playerList) do
  230.                                 minigame.players[name]={
  231.                                         facing=1,
  232.                                         cooldown=0
  233.                                         }
  234.                                 end
  235.                         end,
  236.                 loop=function(time,remaining)
  237.                         if alive==1 then
  238.                                 local survivor=getAlivePlayers()[1]
  239.                                 tfm.exec.chatMessage("<J><b>"..survivor.."</b> kicked butt!")
  240.                                 tfm.exec.giveWin(survivor)
  241.                         elseif remaining<15000 then
  242.                                 if not minigame.lava then
  243.                                         minigame.lava=true
  244.                                         tfm.exec.chatMessage("<J><b>Sudden death!!</b> Stay on screen!")
  245.                                 else
  246.                                         for name,player in pairs(tfm.get.room.playerList) do
  247.                                                 if player.y<0 or player.x<0 or player.x>800 then
  248.                                                         tfm.exec.killPlayer(name)
  249.                                                         end
  250.                                                 end
  251.                                         end
  252.                                 end
  253.                         end,
  254.                 keys={
  255.                         LEFT=function(name)
  256.                                 minigame.players[name].facing=0
  257.                                 end,
  258.                         RIGHT=function(name)
  259.                                 minigame.players[name].facing=1
  260.                                 end,
  261.                         DOWN=function(name,x,y)
  262.                                 local timestamp=tonumber(os.time())
  263.                                 if timestamp-minigame.players[name].cooldown>=1000 then
  264.                                         minigame.players[name].cooldown=timestamp
  265.                                         if minigame.players[name].facing==0 then
  266.                                                 tfm.exec.addShamanObject(20,x+10,y+15)
  267.                                         else
  268.                                                 tfm.exec.addShamanObject(19,x-10,y+15)
  269.                                                 end
  270.                                         end
  271.                                 end
  272.                         }
  273.                 },
  274.         --------------------------------------------------
  275.         {       name="Fly",
  276.                 time=60,
  277.                 shaman=false,
  278.                 intro="You can fly! Tap <VP>SPACE<J> to fly!",
  279.                 maps={'@1586626','@17944016','@871739','@1970001','@2439335','@367747','@3060750','@431721','@423670','@1578737','@923878','@1714548','@1578909','@1578851','@1578868','@1501237','@1224534','@1134543','@896157','@1134474','@999125','@999585','@891035','@926203','@764026','@717845','@577496','@573527','@197503','@2227644','@3054424','@436128','@1196336','@3008334','@1622242','@2113338','@379805','@187088','@421185','@164663','@335361','@146615','@186695','@181261','@201606','@155415','@455094','@433483','@294500','@318970','@211248','@180035','@3731774','@3599104','@3494281'},
  280.                 keys={
  281.                         SPACE=function(name)
  282.                                 tfm.exec.movePlayer(name,0,0,true,0,-50,true)
  283.                                 end
  284.                         }
  285.                 },
  286.         --------------------------------------------------
  287.         {       name="Hill",
  288.                 time=30,
  289.                 shaman=false,
  290.                 intro="Don't fall off!",
  291.                 maps={"@3998037","@4025101"},
  292.                 loop=function(time,remaining)
  293.                         if alive==1 or remaining<=1000 then
  294.                                 tfm.exec.giveWinAll()
  295.                                 end
  296.                         end
  297.                 },
  298.         --------------------------------------------------
  299.         {       name="Launch",
  300.                 time=60,
  301.                 shaman=true,
  302.                 intro="Click on mice with rotated arrows to launch them!",
  303.                 maps={"#4"},
  304.                 summoned=function(name,object,x,y,angle)
  305.                         if object==0 then
  306.                                 for name,player in pairs(tfml.get.room.playerList) do
  307.                                         if pythag(x,y,30,player.x,player.y,30) then
  308.                                                 local xv=Math.cos(angle)*10
  309.                                                 local yv=Math.sin(angle)*10
  310.                                                 tfm.exec.movePlayer(name,0,0,false,xv,yv,true)
  311.                                                 end
  312.                                         end
  313.                                 end
  314.                         end
  315.                 },
  316.         --------------------------------------------------
  317.         {       name="Push",
  318.                 time=45,
  319.                 shaman=false,
  320.                 intro="Push the box off of the map!",
  321.                 maps={"@3995576","@425860","@3997537","@3997576"},
  322.                 boxes={{735,290},{91,194},{91,302},{118,212}},
  323.                 prep=function()
  324.                         local box=minigame.boxes[minigame.mapIndex]
  325.                         minigame.box=tfm.exec.addShamanObject(1,box[1],box[2])
  326.                         end,
  327.                 loop=function()
  328.                         local box=tfm.get.room.objectList[minigame.box]
  329.                         if box and box.y>400 or box.x>800 or box.x<0 then
  330.                                 minigame.won=true
  331.                                 tfm.exec.setGameTime(15)
  332.                                 tfm.exec.chatMessage("<J>You sure showed that box!")
  333.                                 for name,player in pairs(tfm.get.room.playerList) do
  334.                                         minigame.box=nil
  335.                                         if math.abs(box.x-player.x)<90 then
  336.                                                 tfm.exec.giveCheese(name)
  337.                                         else
  338.                                                 tfm.exec.killPlayer(name)
  339.                                                 end
  340.                                         end
  341.                                 end
  342.                         end
  343.                 },
  344.         --------------------------------------------------
  345.         {       name="Simon",
  346.                 time=30,
  347.                 shaman=false,
  348.                 intro="Simon says...",
  349.                 maps={"0"},
  350.                 prep=function()
  351.                         minigame.simon=nil
  352.                         minigame.switch=0
  353.                         end,
  354.                 loop=function(time,remaining)
  355.                         local timestamp=tonumber(os.time())
  356.                         if timestamp-minigame.switch>=2000 then
  357.                                 minigame.switch=timestamp
  358.                                 local says={"Dance","Laugh","Cry","Kiss","Rage","Clap","Sleep","Facepaw","Sit","Throw confetti"}
  359.                                 minigame.simon=math.random(1,#says)-1
  360.                                 tfm.exec.chatMessage("<V>[Simon] <CH><b>"..says[minigame.simon+1].."!</b>")
  361.                                 end
  362.                         end,
  363.                 emote=function(name,emote)
  364.                         if emote==minigame.simon then
  365.                                 tfm.exec.setPlayerScore(name,1,true)
  366.                         else
  367.                                 tfm.exec.killPlayer(name)
  368.                                 tfm.exec.chatMessage("<span color='#F0A78E'>[<b>Simon</b>] I didn't say do that!</span>",name)
  369.                                 end
  370.                         end
  371.                 },
  372.         --------------------------------------------------
  373.         {       name="Smash",
  374.                 time=60,
  375.                 shaman=true,
  376.                 intro="The shaman can throw mice! Beware, little girls!",
  377.                 maps={"#10"},
  378.                 loop=function(time,remaining)
  379.                         if remaining<=1000 then
  380.                                 minigame.won=true
  381.                                 for name,player in pairs(tfm.get.room.playerList) do
  382.                                         if not player.isDead and not player.isShaman then
  383.                                                 tfm.exec.giveWin(name)
  384.                                                 end
  385.                                         end
  386.                         elseif alive==1 then
  387.                                 tfm.exec.giveWinAll()
  388.                                 end
  389.                         end,
  390.                 summon=function(name,object,x,y,angle)
  391.                         if object==24 then
  392.                                 if minigame.selected then
  393.                                         local xOffset=x-minigame.xClick
  394.                                         local yOffset=y-minigame.yClick
  395.                                         tfm.exec.movePlayer(minigame.selected,0,0,true,xOffset,yOffset,true)
  396.                                         minigame.selected=nil
  397.                                 else
  398.                                         for name,player in pairs(tfm.get.room.playerList) do
  399.                                                 if pythag(x,y,30,player.x,player.y,30) then
  400.                                                         minigame.selected=name
  401.                                                         minigame.xClick=x
  402.                                                         minigame.yClick=y
  403.                                                         break
  404.                                                         end
  405.                                                 end
  406.                                         end
  407.                                 end
  408.                         end
  409.                 },
  410.         --------------------------------------------------
  411.         {       name="Spiritjump",
  412.                 time=30,
  413.                 shaman=false,
  414.                 intro="<VP>DUCK<J> to spiritjump!",
  415.                 maps={"#7"},
  416.                 keys={
  417.                         DOWN=function(name,x,y)
  418.                                 tfm.exec.addShamanObject(24,x,y+15)
  419.                                 end
  420.                         }
  421.                 },
  422.         --------------------------------------------------
  423.         {       name="Teleport",
  424.                 time=60,
  425.                 shaman=true,
  426.                 intro="The shaman can spawn portals anywhere with arrows!",
  427.                 maps={"#4"},
  428.                 prep=function()
  429.                         minigame.portal=-1
  430.                         end,
  431.                 summoned=function(name,object,x,y,angle)
  432.                         if object==0 then
  433.                                 minigame.portal=minigame.portal*-1
  434.                                 tfm.exec.addShamanObject(minigame.portal==1 and 26 or 27,x,y)
  435.                                 end
  436.                         end
  437.                 },
  438.         --------------------------------------------------
  439.         {       name="Trivia",
  440.                 time=30,
  441.                 shaman=false,
  442.                 intro="Choices will appear every 5 seconds, <VP>DUCK<J> to choose the current one!",
  443.                 maps={0},
  444.                 trivia={
  445.                         {       q="Who created Transformice?",
  446.                                 a={     "Humans",
  447.                                         "Mice",
  448.                                         "Someone",
  449.                                         "Nobody"
  450.                                         }
  451.                                 },
  452.                         {       q="Who made Bafflua?",
  453.                                 a={     "Fxie and her sidekick Shamousey",
  454.                                         "Fxie",
  455.                                         "Shamousey",
  456.                                         "Baffler"
  457.                                         }
  458.                                 },
  459.                         {       q="What is Lua?",
  460.                                 q={     "A language from Brazil",
  461.                                         "The thing Transformice uses for minigames",
  462.                                         "The Earth's moon",
  463.                                         "A good scripting language"
  464.                                         }
  465.                                 },
  466.                         {       q="Would you consider this a question.",
  467.                                 a={     "No",
  468.                                         "Yes",
  469.                                         "There is no question and therefor no answer",
  470.                                         "<no answer>"
  471.                                         }
  472.                                 },
  473.                         {       q="What sound does a mouse make?",
  474.                                 a={     "Squeak",
  475.                                         "Meep",
  476.                                         "*-*",
  477.                                         "Moo"
  478.                                         }
  479.                                 },
  480.                         {       q="Did Baffbot wear an afro?",
  481.                                 a={     "He wore glasses",
  482.                                         "No",
  483.                                         "Yes",
  484.                                         "It depends on your definition of afro"
  485.                                         }
  486.                                 },
  487.                         {       q="Which answer is the correct one?",
  488.                                 a={     "Every answer is both right and wrong",
  489.                                         "This one!",
  490.                                         "This one, the others are false",
  491.                                         "Either A, B, C, or D."
  492.                                         }
  493.                                 },
  494.                         {       q="How long is a week?",
  495.                                 a={     "Weeks do not have a length",
  496.                                         "7 days",
  497.                                         "5 days",
  498.                                         "It depends if it's a work week"
  499.                                         }
  500.                                 },
  501.                         {       q="What color are my socks?",
  502.                                 a={     "What socks?",
  503.                                         "Pink polka-dot",
  504.                                         "Translucent",
  505.                                         "I don't know!"
  506.                                         }
  507.                                 },
  508.                         {       q="Choose your answer.",
  509.                                 a={ "<no answer>",
  510.                                         "No",
  511.                                         "The answer is yes",
  512.                                         "This is the correct answer"
  513.                                         }
  514.                                 },
  515.                         {       q="Is the cup half full or half empty?",
  516.                                 a={     "The cup is entirely empty",
  517.                                         "It's half full",
  518.                                         "It's half empty",
  519.                                         "I'm not playing your mind games"
  520.                                         }
  521.                                 },
  522.                         {       q="If a tree falls in a forest and no one is around to hear it, does it make a sound?",
  523.                                 a={     "It depends",
  524.                                         "No, because someone must exist to decide what is and is not sound",
  525.                                         "Yes, because the mice can hear it",
  526.                                         "Maybe, depending if less self-important animals are around"
  527.                                         }
  528.                                 }
  529.                         },
  530.                 prep=function()
  531.                         local q=table.random(minigame.trivia)
  532.                         local aTemp={}
  533.                         minigame.a=q.a[1]
  534.                         minigame.on=nil
  535.                         for i=1,#q.a,1 do
  536.                                 table.insert(aTemp,q.a[i])
  537.                                 end
  538.                         minigame.aList={}
  539.                         for i=1,#aTemp,1 do
  540.                                 local index=math.random(#aTemp)
  541.                                 table.insert(minigame.aList,aTemp[index])
  542.                                 table.remove(aTemp,index)
  543.                                 end
  544.                         tfm.exec.chatMessage("<ROSE>[<b>Question</b>] "..q.q)
  545.                         timer=system.newTimer(function()
  546.                                 minigame.on=minigame.aList[1]
  547.                                 tfm.exec.chatMessage("<J><b>A.</b> "..minigame.on)
  548.                                 timer=system.newTimer(function()
  549.                                         minigame.on=minigame.aList[2]
  550.                                         tfm.exec.chatMessage("<J><b>B.</b> "..minigame.on)
  551.                                         timer=system.newTimer(function()
  552.                                                 minigame.on=minigame.aList[3]
  553.                                                 tfm.exec.chatMessage("<J><b>C.</b> "..minigame.on)
  554.                                                 timer=system.newTimer(function()
  555.                                                         minigame.on=minigame.aList[4]
  556.                                                         tfm.exec.chatMessage("<J><b>D.</b> "..minigame.on)
  557.                                                         end,5000)
  558.                                                 end,5000)
  559.                                         end,5000)
  560.                                 end,5000)
  561.                         end,
  562.                 keys={
  563.                         DOWN=function(name,x,y)
  564.                                 if minigame.on==minigame.a then
  565.                                         tfm.exec.chatMessage("<J><b>"..name.."</b> knew the answer!")
  566.                                         tfm.exec.giveWin(name)
  567.                                         for name,player in pairs(tfm.get.room.playerList) do
  568.                                                 tfm.exec.killPlayer(name)
  569.                                                 end
  570.                                 else
  571.                                         tfm.exec.chatMessage("<R>WRONG!",name)
  572.                                         tfm.exec.killPlayer(name)
  573.                                         end
  574.                                 end
  575.                         }
  576.                 },
  577.         --------------------------------------------------
  578.         {       name="Walljump"
  579.                 time=60,
  580.                 shaman=false,
  581.                 intro="Walljump to stay alive!",
  582.                 maps={"@4025303"},
  583.                 loop=function(time,remaining)
  584.                         if time>5000 then
  585.                                 local gravity=(time-5000)/5000
  586.                                 for name,player in pairs(tfm.get.room.playerList) do
  587.                                         tfm.exec.movePlayer(name,0,0,false,0,gravity,true)
  588.                                         end
  589.                         elseif alive==1 or remaining<=1000 then
  590.                                 tfm.exec.giveWinAll()
  591.                                 end
  592.                         end,
  593.                 }
  594.         }
  595.  
  596. --Readable keys to playable keys
  597. for i=1,#games,1 do
  598.         local mini=games[i]
  599.         if mini.keys then
  600.                 local newKeys={}
  601.                 for key,fnc in pairs(mini.keys) do
  602.                         if key=="SPACE" then
  603.                                 newKeys[32]=fnc
  604.                         elseif key=="UP" then
  605.                                 newKeys[38]=fnc
  606.                                 newKeys[87]=fnc
  607.                         elseif key=="DOWN" then
  608.                                 newKeys[40]=fnc
  609.                                 newKeys[83]=fnc
  610.                         elseif key=="LEFT" then
  611.                                 newKeys[37]=fnc
  612.                                 newKeys[64]=fnc
  613.                                 newKeys[81]=fnc
  614.                         elseif key=="RIGHT" then
  615.                                 newKeys[39]=fnc
  616.                                 newKeys[68]=fnc
  617.                                 end
  618.                         end
  619.                 mini.keys=newKeys
  620.                 end
  621.         end
  622.  
  623. --Useful.lua
  624. function table.random(table)
  625.         return table[math.random(1,#table)]
  626.         end
  627. function table.contains(table,element)
  628.         for key,value in pairs(table) do
  629.                 if value==element then
  630.                         return true
  631.                         end
  632.                 end
  633.         return false
  634.         end
  635.  
  636. --Useful.tfm
  637. function tfm.exec.giveWin(name)
  638.         tfm.exec.giveCheese(name)
  639.         tfm.exec.playerVictory(name)
  640.         end
  641. function tfm.exec.giveWinAll()
  642.         for name,player in pairs(tfm.get.room.playerList) do
  643.                 if not player.isDead then
  644.                         tfm.exec.giveWin(name)
  645.                         end
  646.                 end
  647.         end
  648. function tfm.exec.getShaman()
  649.         for name,player in pairs(tfm.get.room.playerList) do
  650.                 if player.isShaman then
  651.                         return name
  652.                         end
  653.                 end
  654.         end
  655. function getPlayer(name)
  656.         return tfm.get.room.playerList[name]
  657.         end
  658. function getAlivePlayers()
  659.         local alivePlayers={}
  660.         for name,player in pairs(tfm.get.room.playerList) do
  661.                 if not player.isDead then
  662.                         table.insert(alivePlayers,name)
  663.                         end
  664.                 end
  665.         return alivePlayers
  666.         end
  667. function makeTeams(fncRed,fncBlue)
  668.         local players={}
  669.         local teams={
  670.                 red={},
  671.                 blue={}
  672.                 }
  673.         for name,player in pairs(tfm.get.room.playerList) do
  674.                 table.insert(players,name)
  675.                 end
  676.         for i=1,#players,1 do
  677.                 local index=math.random(#players)
  678.                 local player=players[index]
  679.                 if i%2==0 then
  680.                         if fncRed then fncRed() end
  681.                         table.insert(teams.red,player)
  682.                 else
  683.                         if fncBlue then fncBlue() end
  684.                         table.insert(teams.blue,player)
  685.                         end
  686.                 table.remove(players,index)
  687.                 end
  688.         return teams
  689.         end
  690.  
  691. --Collision detection (circles)
  692. function pythag(x1,y1,r1,x2,y2,r2)
  693.         local x=x2-x1
  694.         local y=y2-y1
  695.         local r=r2+r1
  696.         return x*x+y*y<r*r
  697.         end
  698.  
  699. --Marblecake AKA The Game
  700. lastmode=-1
  701. function switchGame(mode,map)
  702.         if timer then
  703.                 system.removeTimer(timer)
  704.                 timer=nil
  705.                 end
  706.         setAllKeys(false)
  707.         while not mode do
  708.                 mode=math.random(#games)
  709.                 if mode==lastmode then mode=nil end
  710.                 end
  711.         lastmode=mode
  712.         minigame=games[mode]
  713.         if minigame.delay then
  714.                 minigame.ready=false
  715.         else
  716.                 setAllKeys(true)
  717.                 end
  718.         minigame.won=false
  719.         tfm.exec.disableAutoShaman(not minigame.shaman)
  720.         minigame.mapIndex=math.random(#minigame.maps)
  721.         minigame.mapCode=map or minigame.maps[minigame.mapIndex]
  722.         tfm.exec.newGame(minigame.mapCode)
  723.         end
  724.  
  725. --New game initialisation
  726. function eventNewGame()
  727.         tfm.exec.setGameTime(minigame.time)
  728.         tfm.exec.chatMessage("<J>"..minigame.intro)
  729.         alive=0
  730.         for name,player in pairs(tfm.get.room.playerList) do
  731.                 alive=alive+1
  732.                 if not player.isShaman then
  733.                         tfm.exec.setNameColor(name,0)
  734.                         end
  735.                 end
  736.         if minigame.prep then minigame.prep() end
  737.         end
  738.  
  739. --Events
  740. function eventLoop(time,remaining)
  741.         if minigame.delay and not minigame.ready and time>minigame.delay*1000 then
  742.                 minigame.ready=true
  743.                 setAllKeys(true)
  744.         elseif not minigame.won and minigame.loop and (not minigame.delay or minigame.ready) then
  745.                 minigame.loop(time,remaining)
  746.                 end
  747.         if remaining<=0 or alive==0 then
  748.                 switchGame()
  749.                 end
  750.         end
  751.  --Keyboard functions
  752. function setAllKeys(active)
  753.         if minigame and minigame.keys then
  754.                 for key,fnc in pairs(minigame.keys) do
  755.                         for name,player in pairs(tfm.get.room.playerList) do
  756.                                 tfm.exec.bindKeyboard(name,key,true,active)
  757.                                 end
  758.                         end
  759.                 end
  760.         end
  761.  
  762. function eventKeyboard(name,key,down,x,y)
  763.         if not getPlayer(name).isDead and minigame.keys then
  764.                 for code,fnc in pairs(minigame.keys) do
  765.                         if key==code then
  766.                                 fnc(name,x,y)
  767.                                 end
  768.                         end
  769.                 end
  770.         end
  771.  
  772. --Emotional
  773. function eventEmotePlayed(name,emote)
  774.         if minigame.emote then
  775.                 minigame.emote(name,emote)
  776.                 end
  777.         end
  778.  
  779. --Summoning functions
  780. function eventSummoningStart(name,object,x,y,angle)
  781.         if minigame.summon then
  782.                 minigame.summon(name,object,x,y,angle)
  783.                 end
  784.         end
  785. function eventSummoningEnd(name,object,x,y,angle)
  786.         if minigame.summoned then
  787.                 minigame.summoned(name,object,x,y,angle)
  788.                 end
  789.         end
  790.  
  791. function eventPlayerDied(name)
  792.         alive=alive-1
  793.         end
  794.  
  795. function eventPlayerWon(name)
  796.         alive=alive-1
  797.         end
  798.  
  799. --Chat commands
  800. system.disableChatCommandDisplay("help")
  801. system.disableChatCommandDisplay("games")
  802. system.disableChatCommandDisplay("skip")
  803. system.disableChatCommandDisplay("cheese")
  804. system.disableChatCommandDisplay("kill")
  805. system.disableChatCommandDisplay("play")
  806. function eventChatCommand(name,message)
  807.         local split=string.find(message," ") or #message+1
  808.         local cmd=string.sub(message,1,split-1)
  809.         local args=string.sub(message,split+1)
  810.         if cmd=="help" then
  811.                 tfm.exec.chatMessage("U NEED SUM HELP?!",name)
  812.         elseif cmd=="games" then
  813.                 local list="<J>Current minigames: "
  814.                 for i=1,#games,1 do
  815.                         list=list.."<b>"..games[i].name.."</b>, "
  816.                         end
  817.                 tfm.exec.chatMessage(list.."and who knows what else!",name)
  818.         elseif table.contains(admins,name) then
  819.                 if cmd=="skip" or cmd=="next" then
  820.                         switchGame()
  821.                 elseif cmd=="cheese" then
  822.                         tfm.exec.giveCheese(name)
  823.                 elseif cmd=="kill" then
  824.                         tfm.exec.killPlayer(args)
  825.                 elseif cmd=="play" then
  826.                         for i=1,#games,1 do
  827.                                 if games[i].name==args then
  828.                                         tfm.exec.setPlayerScore(name,100,true)
  829.                                         switchGame(i)
  830.                                         break
  831.                                         end
  832.                                 end
  833.                         end
  834.                 end
  835.         end
  836.  
  837. --Geral á minha humilde morada
  838. function eventNewPlayer(name)
  839.         tfm.exec.chatMessage("<ROSE><b>"..table.random(greets).."</b>",name)
  840.         end
  841.  
  842. --Bafflua é online!
  843. for name,player in pairs(tfm.get.room.playerList) do
  844.         eventNewPlayer(name)
  845.         end
  846. switchGame()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement