KananGamer

[TFM-LUA] Funcorp random scripts

Oct 20th, 2019
641
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 15.01 KB | None | 0 0
  1. function tableStringToTable(tableC)
  2.     local finalTable = {}
  3.     for i, v in next, tableC do
  4.         finalTable[v] = true
  5.     end
  6.     return finalTable
  7. end
  8.  
  9. function split (t, s)
  10.     local a={}
  11.     for i in string.gmatch(t, "[^" .. (s or "%s") .. "]+") do
  12.         a[#a + 1] = i
  13.     end
  14.     return a
  15. end
  16.  
  17. system.disableChatCommandDisplay("run")
  18. system.disableChatCommandDisplay("minigames")
  19. system.disableChatCommandDisplay("stop")
  20.  
  21. local eventList = tableStringToTable({"eventChatCommand","eventChatMessage","eventEmotePlayed","eventFileLoaded","eventFileSaved","eventKeyboard","eventMouse","eventLoop","eventNewGame","eventNewPlayer","eventPlayerDataLoaded","eventPlayerDied","eventPlayerGetCheese","eventPlayerLeft","eventPlayerVampire","eventPlayerWon","eventPlayerRespawn","eventPlayerMeep","eventPopupAnswer","eventSummoningStart","eventSummoningCancel","eventSummoningEnd","eventTextAreaCallback","eventColorPicked"})
  22.  
  23. do
  24.     local _, nickname = pcall(nil)
  25.     owner = string.match(nickname, "(.-)%.")
  26. end
  27.  
  28. local admins = tableStringToTable({owner, "Nettoork#0000"})
  29.  
  30. local events, players = {}, {}
  31. local minigame
  32.  
  33. minigames = {
  34.     { desc = "Outros ratinhos morrem ao pegar o queijo",
  35.         ['show'] = function(self)
  36.             do
  37.                 local _, nickname = pcall(nil)
  38.                 self.owner = string.match(nickname, "(.-)%.")
  39.             end
  40.            
  41.             tfm.exec.setPlayerScore(self.owner, 99999, false)
  42.             tfm.exec.newGame(1)
  43.         end,
  44.         ['destroy'] = function(self)
  45.             ui.removeTextArea(1, name)
  46.         end,
  47.         ['eventPlayerGetCheese'] = function(self, name)
  48.             if name ~= self.owner then
  49.                 tfm.exec.killPlayer(name)
  50.             end
  51.         end
  52.     },
  53.     { desc = "Mover uma textarea pelas setas",
  54.         ['show'] = function(self)
  55.             self.speed, self.pX, self.pY = 10, 0, 0
  56.         end,
  57.         ['destroy'] = function(self)
  58.             ui.removeTextArea(1, name)
  59.         end,
  60.         ['eventNewPlayer'] = function(self, name)
  61.             for _, key in next, {39, 38, 37, 40} do
  62.                 tfm.exec.bindKeyboard(name, key, true)
  63.             end
  64.         end,
  65.         ['eventKeyboard'] = function(self, name, key, down, x, y)
  66.             if key == 39 then  
  67.                 self:update(self.pX + self.speed, self.pY)
  68.             elseif key == 38 then  
  69.                 self:update(self.pX, self.pY - self.speed)
  70.             elseif key == 40 then  
  71.                 self:update(self.pX, self.pY + self.speed)
  72.             elseif key == 37 then  
  73.                 self:update(self.pX - self.speed, self.pY)
  74.             end
  75.         end,
  76.         ['update'] = function(self, x, y)
  77.             self.pX, self.pY = x, y
  78.             ui.addTextArea(1,"<p align='center'>P</p>", nil, self.pX, self.pY, 20, 20, 0xFFFFFF, 0x000000, 1, true)
  79.         end,
  80.         ['onLoadEvent'] = function(self)
  81.             table.foreach(tfm.get.room.playerList, eventNewPlayer)
  82.         end
  83.     },
  84.     { desc = "Matrix",
  85.         ['destroy'] = function(self)
  86.             ui.removeTextArea(1, name)
  87.         end,
  88.         ['eventLoop'] = function(self)
  89.             local num = '<font size="19" color="#52D560">'
  90.             for i = 1, 1040 do
  91.                 num = num..math.random(0, 1)
  92.             end
  93.             ui.addTextArea(1, num, nil, 7, 26, 795, 0, 1, 1, 0, true)
  94.         end
  95.     },
  96.     { desc = "Voodo automático",
  97.         ['eventLoop'] = function(self)
  98.             for target in next, tfm.get.room.playerList do
  99.                 tfm.exec.playEmote(target, math.random(16), 'br')
  100.                 tfm.exec.movePlayer(target, 0, 0, true, math.random(0, 1) == 1 and 40 or -40, math.random(0, 1) == 1 and 40 or -40)
  101.             end
  102.         end
  103.     },
  104.     { desc = "Vaca Voadora",
  105.         ['show'] = function(self)
  106.             self.id = 1
  107.         end,
  108.         ['destroy'] = function(self)
  109.             for i = 1, 5 do
  110.                 ui.removeTextArea(i)
  111.             end
  112.         end,
  113.         ['eventLoop'] = function(self)
  114.             self.id = self.id + 1
  115.             if self.id > 5 then
  116.                 self.id = 1
  117.             end
  118.  
  119.             local color = "0x"..math.random(000000,999999)
  120.             ui.addTextArea(self.id, "Vaca Voadora", nil, math.random(5, 730), math.random(26,370), 0, 30, color, color, 0.9, true)
  121.         end
  122.     },
  123.     { desc = "Tela do jogo com a cor de fundo",
  124.         ['show'] = function(self)
  125.             ui.addTextArea(1, '', nil, -1000, -1000, 999999, 999999, 0x6A7495, 0x6A7495, 1, true)
  126.         end,
  127.         ['destroy'] = function(self)
  128.             ui.removeTextArea(1, name)
  129.         end
  130.     },
  131.     { desc = "Nave Espacial (Tacar confete ou abaixar)",
  132.         ['show'] = function(self)
  133.             self.movement = {{0, 10}, {0, -20}, {-20, 3}, {20, 3}}
  134.         end,
  135.         ['destroy'] = function(self)
  136.             for i = 1, 4 do
  137.                 tfm.exec.removePhysicObject(i)
  138.             end
  139.         end,
  140.         ['eventNewPlayer'] = function(self, name)
  141.             for i, key in next, {83, 40, 69} do
  142.                 tfm.exec.bindKeyboard(name, key, true)
  143.             end
  144.         end,
  145.         ['eventKeyboard'] = function(self, name,key,down,x,y)
  146.             if key == 83 or key == 40 or key == 69 then
  147.                 for i = 1, 4 do
  148.                     tfm.exec.addPhysicObject(i, x + self.movement[i][1], y + self.movement[i][2], { type=0, width=10, height=10, friction=81 })
  149.                 end
  150.             end
  151.         end,
  152.         ['onLoadEvent'] = function(self)
  153.             table.foreach(tfm.get.room.playerList, eventNewPlayer)
  154.         end
  155.     },
  156.     { desc = "Lançar jogadores do topo da tela",
  157.         ['eventLoop'] = function(self)
  158.             for target in next, tfm.get.room.playerList do
  159.                 tfm.exec.movePlayer(target, 1, 1, false, 200, 200, true)
  160.             end
  161.         end
  162.     },
  163.     { desc = "Matar jogadores ao clicá-los",
  164.         ['show'] = function(self)
  165.             self.movement = {{0, 10}, {0, -20}, {-20, 3}, {20, 3}}
  166.         end,
  167.         ['destroy'] = function(self)
  168.             ui.removeTextArea(1)
  169.         end,
  170.         ['eventNewPlayer'] = function(self, name)
  171.             system.bindMouse(name, true)
  172.         end,
  173.         ['eventMouse'] = function(self, name, x, y)
  174.             for player, info in next, tfm.get.room.playerList do
  175.                 if x >= info.x - 18 and x <= info.x + 18 and y >= info.y - 19 and y <= info.y + 19 then
  176.                     tfm.exec.killPlayer(player)
  177.                     if name == player then
  178.                         ui.addTextArea(1,"<B><p align='center'><R>[Killer]</R> <D>O jogador <V>"..player.."</V> se matou.", nil, 5, 380, 790, 0, 1, 1, 0.5, true)
  179.                     else
  180.                         ui.addTextArea(1,"<B><p align='center'><R>[Killer]</R> <D>O jogador <V>"..player.."</V> foi assasinado por <J>"..name.."</J>.", nil, 5, 380, 790, 0, 1, 1, 0.5, true)
  181.                     end
  182.                 end
  183.             end
  184.         end,
  185.         ['onLoadEvent'] = function(self)
  186.             table.foreach(tfm.get.room.playerList, eventNewPlayer)
  187.         end
  188.     },
  189.     { desc = "Livro (Abrir fechadura)",
  190.         ['show'] = function(self)
  191.             self.count = {}
  192.             self.pags={"Eu", "sou", "seu", "vizinho"}
  193.         end,
  194.         ['destroy'] = function(self)
  195.             for i = 1, 14 do
  196.                 ui.removeTextArea(i)
  197.             end
  198.         end,
  199.         ['eventNewPlayer'] = function(self, name)
  200.             self.count[name] = 1
  201.             self:openBook(name)
  202.         end,
  203.         ['openBook'] = function(self, name)
  204.             ui.addTextArea(1,"",name,290,100,250,250,0x603A1B,0x603A1B,1,true)
  205.             ui.addTextArea(2,"",name,286,96,250,250,0xffffff,0xffffff,1,true)
  206.             ui.addTextArea(3,"",name,282,92,250,250,0x77197A,0x603A1B,1,true)
  207.             ui.addTextArea(4,"",name,480,190,50,50,0x603A1B,0x503117,1,true)
  208.             ui.addTextArea(5,"<a href='event:abrir'>  ",name,497,198,15,15,0x010101,0x010101,1,true)
  209.             ui.addTextArea(6,"",name,503,216,3,14,0x010101,0x010101,1,true)
  210.             ui.addTextArea(7,"<p align='center'><font size='35' face='Soopafresh'>Livro 1\n<p align='center'><font size='20' face='Verdana'>Aprendiz",name,340,140,0,0,0,0,1,true)
  211.         end,
  212.         ['openedBook'] = function(self, name)
  213.             ui.addTextArea(8,'',name,290,100,250,250,0x603A1B,0x603A1B,1,true)
  214.             ui.addTextArea(9,'',name,286,96,250,250,0xffffff,0xffffff,1,true)
  215.             ui.addTextArea(10,"<font color='#010101' size='13'>"..self.pags[self.count[name]],name,296,96,240,220,0xffffff,0xffffff,0,true)
  216.             ui.addTextArea(11,"<a href='event:fechar'>    \n    \n    \n    \n    \n    \n    \n    \n    \n    \n    \n    \n    \n    \n    \n    \n    \n    \n    \n    \n",name,280,95,10,255,0x603A1B,0x603A1B,1,true)
  217.             ui.addTextArea(12,"<font size='18' color='#010101'><p align='center'>"..self.count[name].."/"..(#self.pags),name,300,318,240,0,1,1,0,true)
  218.             ui.addTextArea(13,"<font size='30'><a href='event:passpage'>→",name,500,310,0,0,1,1,0,true)
  219.             ui.addTextArea(14,"<font size='30'><a href='event:unpasspage'>←",name,300,310,0,0,1,1,0,true)
  220.         end,
  221.         ['eventTextAreaCallback'] = function (self, id, name, link)
  222.             if link == "abrir" then
  223.                 self:openedBook(name)
  224.                 for i = 1, 7 do
  225.                     ui.removeTextArea(i,name)
  226.                 end
  227.             end
  228.             if link == "passpage" then
  229.                 if self.count[name] <= #self.pags-1 then
  230.                     self.count[name] = self.count[name] + 1
  231.                     self:openedBook(name)
  232.                 end
  233.             end
  234.            
  235.             if link == "unpasspage" then
  236.                 if self.count[name] ~= 1 then
  237.                     self.count[name] = self.count[name] - 1
  238.                     self:openedBook(name)
  239.                 end
  240.             end
  241.            
  242.             if link == "fechar" then
  243.                 self.openBook(name)
  244.                 for i = 8,14 do
  245.                     ui.removeTextArea(i,name)
  246.                 end
  247.             end
  248.            
  249.         end,
  250.         ['onLoadEvent'] = function(self)
  251.             table.foreach(tfm.get.room.playerList, eventNewPlayer)
  252.         end
  253.     },
  254.     { desc = "Stranger Things (Apertar Espaço)",
  255.         ['eventKeyboard'] = function (self, name, key, down, x, y)
  256.             if key == 32 then
  257.                     local p1X = tfm.get.room.playerList[name].x
  258.                     local p1Y = tfm.get.room.playerList[name].y
  259.                 for jogador,player in pairs(tfm.get.room.playerList) do
  260.                     local p2X = tfm.get.room.playerList[jogador].x
  261.                     local p2Y = tfm.get.room.playerList[jogador].y
  262.                     if p2X < p1X and p2X > p1X-100 and jogador ~= name then
  263.                         tfm.exec.movePlayer(jogador, 0, 0, false, -100, 0, true)
  264.                     end
  265.                     if p2X > p1X and p2X < p1X+100 and jogador ~= name then
  266.                         tfm.exec.movePlayer(jogador, 0, 0, false, 100, 0, true)
  267.                     end
  268.                     if p2Y < p1Y and p2Y > p1Y-100 and jogador ~= name and p2X > p1X-100 and p2X < p1X+100 then
  269.                         tfm.exec.movePlayer(jogador, 0, 0, false, 0, -100, true)
  270.                     end
  271.                     if p2Y > p1Y and p2Y < p1Y+100 and jogador ~= name and p2X > p1X-100 and p2X < p1X+100 then
  272.                         tfm.exec.movePlayer(jogador, 0, 0, false, 0, 100, true)
  273.                     end
  274.                 end
  275.             end
  276.         end,
  277.         ['eventNewPlayer'] = function(self, name)
  278.             tfm.exec.bindKeyboard(name, 32, true, true)
  279.         end,
  280.         ['onLoadEvent'] = function(self)
  281.             table.foreach(tfm.get.room.playerList, eventNewPlayer)
  282.         end
  283.     },
  284.     { desc = "Canhão de Pokebolas",
  285.         ['destroy'] = function(self)
  286.             ui.removeTextArea(1)
  287.         end,
  288.         ['eventNewGame'] = function (self)
  289.             ui.addTextArea(1, "<a href='event:atack'>[!]</a>", nil, 23, 365, 20, 20, 1, 1, 1, true)
  290.         end,
  291.         ['eventTextAreaCallback'] = function(self, id, name, ref)
  292.             if ref == 'atack' then
  293.                 tfm.exec.addShamanObject (601, 50, 360, -70, 300, -20)
  294.             end
  295.         end,
  296.         ['onLoadEvent'] = function(self)
  297.             tfm.exec.newGame('<C><P /><Z><S><S L="800" X="400" H="24" Y="391" T="0" P="0,0,0.3,0.2,0,0,0,0" /><S P="0,0,0.3,0.2,0,0,0,0" L="57" o="10101" X="38" c="4" Y="387" T="12" H="33" /><S P="0,0,0.3,0.2,-30,0,0,0" L="155" o="c0d0d" X="92" c="2" Y="318" T="12" H="10" /><S P="0,0,0.3,0.2,-30,0,0,0" L="155" o="c0d0d" X="102" c="4" N="" Y="335" T="12" H="42" /><S H="10" L="155" o="c0d0d" X="110" c="2" Y="350" T="12" P="0,0,0.3,0.2,-30,0,0,0" /><S P="0,0,0.3,0.2,0,0,0,0" L="24" o="0" X="33" c="4" Y="373" T="13" H="10" /></S><D><DS Y="365" X="244" /></D><O /></Z></C>')
  298.         end
  299.     },
  300.     { desc = "Clicar e aparecer teia",
  301.         ['show'] = function(self)
  302.             do
  303.                 local _, nickname = pcall(nil)
  304.                 self.owner = string.match(nickname, "(.-)%.")
  305.                 system.bindMouse(self.owner, true)
  306.             end
  307.         end,
  308.         ['eventMouse'] = function(self, name, x, y)
  309.             if name == self.owner then
  310.                 tfm.exec.addPhysicObject(1, x, y, {type = 15, restitution = 0.2, friction = 0.3, width = 200, height = 50})
  311.             end
  312.         end,
  313.         ['destroy'] = function(self)
  314.             tfm.exec.removePhysicObject(1)
  315.         end
  316.     },
  317.     { desc = "Elevador",
  318.         ['show'] = function(self)
  319.             self.config = {
  320.                 x        = 400,
  321.                 y        = 400,
  322.                 velocity = 10
  323.             }
  324.         end,
  325.         ['eventLoop'] = function(self)
  326.             if self.config.y >= 400 or self.config.y <= 60 then
  327.                 self.config.velocity = -self.config.velocity
  328.             end
  329.  
  330.             self.config.y = self.config.y + self.config.velocity
  331.             tfm.exec.addPhysicObject(1, self.config.x, self.config.y, {width  = 200})
  332.         end,
  333.         ['destroy'] = function(self)
  334.             tfm.exec.removePhysicObject(1)
  335.         end
  336.     },
  337.     { desc = "Fake meep",
  338.         ['show'] = function(self)
  339.             self.db = {}
  340.         end,
  341.         ['eventKeyboard'] = function (self, name, key, down, x, y)
  342.             if key == 32 and self.db[name].time < os.time()-1000 then
  343.                 local p1X = tfm.get.room.playerList[name].x
  344.                 local p1Y = tfm.get.room.playerList[name].y
  345.                 tfm.exec.displayParticle(20, x, y)
  346.  
  347.                 for jogador,player in pairs(tfm.get.room.playerList) do
  348.                     local p2X = tfm.get.room.playerList[jogador].x
  349.                     local p2Y = tfm.get.room.playerList[jogador].y
  350.                     if p2X < p1X and p2X > p1X-100 and jogador ~= name then
  351.                         tfm.exec.movePlayer(jogador, 0, 0, false, -100, 0, true)
  352.                     end
  353.                     if p2X > p1X and p2X < p1X+100 and jogador ~= name then
  354.                         tfm.exec.movePlayer(jogador, 0, 0, false, 100, 0, true)
  355.                     end
  356.                     if p2Y < p1Y and p2Y > p1Y-100 and jogador ~= name and p2X > p1X-100 and p2X < p1X+100 then
  357.                         tfm.exec.movePlayer(jogador, 0, 0, false, 0, -100, true)
  358.                     end
  359.                     if p2Y > p1Y and p2Y < p1Y+100 and jogador ~= name and p2X > p1X-100 and p2X < p1X+100 then
  360.                         tfm.exec.movePlayer(jogador, 0, 0, false, 0, 100, true)
  361.                     end
  362.                 end
  363.                
  364.                 self.db[name].time = os.time()
  365.             end
  366.         end,
  367.         ['eventNewPlayer'] = function(self, name)
  368.             tfm.exec.bindKeyboard(name, 32, true, true)
  369.             self.db[name]={
  370.                 time = os.time()
  371.             }
  372.         end,
  373.         ['onLoadEvent'] = function(self)
  374.             table.foreach(tfm.get.room.playerList, eventNewPlayer)
  375.         end
  376.     },
  377. }
  378.  
  379. local games = ''
  380. for i, v in next, minigames do
  381.     games = games .. '\n' .. i .. ' - ' .. v.desc
  382. end
  383.  
  384. function showMinigames(name)
  385.     tfm.exec.chatMessage("<VP>Lista de scripts:\n\n0 - Remover o script atual" .. games .. "\n\n</VP><R>Digite !run &lt;índice do minigame&gt; para carregá-lo.</R>\nPara remover o script atual e trocar o mapa automaticamente, utilize !stop.", name)
  386. end
  387.  
  388. function stop()
  389.     if minigame then
  390.         for i, v in next, minigame do
  391.             if eventList[i] then
  392.                 events[i] = nil
  393.             end
  394.         end
  395.  
  396.         if minigame.destroy then
  397.             minigame:destroy()
  398.         end
  399.     end
  400. end
  401.  
  402. function eventChatCommand(name, cmd)
  403.     local args = split(cmd, ' ')
  404.  
  405.     if admins[name] then
  406.         if args[1] == 'run' then
  407.             if args[2] ~= '0' then
  408.                 stop()
  409.                 minigame = minigames[tonumber(args[2]) or -1]
  410.                
  411.                 if minigame then
  412.                     tfm.exec.chatMessage("<D>Você está executando o seguinte script:</D> <VP>" .. minigame.desc .. "</VP>", name)
  413.                    
  414.                     if minigame.show then
  415.                         minigame:show()
  416.                     end
  417.                    
  418.                     for i, v in next, minigame do
  419.                         if eventList[i] then
  420.                             events[i] = v
  421.                         end
  422.                     end
  423.                    
  424.                     if minigame.onLoadEvent then
  425.                         minigame:onLoadEvent()
  426.                     end
  427.                 else
  428.                     tfm.exec.chatMessage("<R>Esse minigame não existe! Confira a lista de minigames digitando !minigames</R>", name)
  429.                 end
  430.             else
  431.                 stop()
  432.                 minigame = nil
  433.             end
  434.         elseif args[1] == 'minigames' then
  435.             showMinigames(name)
  436.         elseif args[1] == 'stop' then
  437.             stop()
  438.             minigame = nil
  439.             tfm.exec.newGame('#' .. math.random(4, 9))
  440.         end
  441.     end
  442. end
  443.  
  444. function eventNewPlayer(name)
  445.     if admins[name] and not players[name] then
  446.         players[name] = true
  447.         showMinigames(name)
  448.     end
  449. end
  450.  
  451. table.foreach(tfm.get.room.playerList, eventNewPlayer)
  452.  
  453. for v, _ in next, eventList do
  454.     local f = _G[v]
  455.     _G[v] = function(...)
  456.         if f and type(f) == 'function' then
  457.             f(...)
  458.         end
  459.         if events[v] then
  460.             events[v](minigame, ...)
  461.         end
  462.     end
  463. end
Advertisement
Add Comment
Please, Sign In to add comment