Advertisement
Bolodefchoco_LUAXML

[Script] #funcorp

Sep 28th, 2018
347
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 8.90 KB | None | 0 0
  1. local owners = { }
  2.  
  3. string.split = function(str, pat)
  4.     local out, counter = { }, 0
  5.  
  6.     string.gsub(str, pat, function(value)
  7.         counter = counter + 1
  8.         out[counter] = tonumber(value) or value
  9.     end)
  10.  
  11.     return out
  12. end
  13.  
  14. string.nick = function(playerName)
  15.     if not string.find(playerName, '#') then
  16.         playerName = playerName .. "#0000"
  17.     end
  18.  
  19.     return (string.gsub(string.lower(playerName), "%a", string.upper, 1))
  20. end
  21.  
  22. local miceAlive, nextMap = 0
  23.  
  24. local funcorp = false
  25. eventChatCommand = function(playerName, command)
  26.     if not owners[playerName] then return end
  27.  
  28.     local cmd = string.split(command, "%S+")
  29.  
  30.     if cmd[1] == "funcorp" then
  31.         if cmd[2] == "help" then
  32.             tfm.exec.chatMessage([[<CE>!changesize [playerNames|*] [size|off] : Temporarily changes the size (between 0.1x and 5x) of players.
  33.            
  34. !colornick [playerNames|*] [color|off] : Temporarily changes the color of player nicknames.
  35.  
  36. !funcorp [on|off|help] : Enable/disable the funcorp mode, or show the list of funcorp-related commands
  37.  
  38. !linkmice [playerNames] [off] : Temporarily links players.
  39.  
  40. !meep [playerNames|*] [off] : Give meep to players.
  41.  
  42. !np [mapCode] : Starts a new map.
  43.  
  44. !npp [mapCode] : Plays the selected map after the current map is over.
  45.  
  46. !transformation [playerNames|*] [off] : Temporarily gives the ability to transform.
  47.             ]], playerName)
  48.         else
  49.             if cmd[2] then
  50.                 funcorp = (cmd[2] == "on" and true or cmd[2] == "off" and false)
  51.             else
  52.                 funcorp = not funcorp
  53.             end
  54.  
  55.             if funcorp then
  56.                 tfm.exec.chatMessage("<CE>The FunCorp mode has been activated in this room.")
  57.             else
  58.                 tfm.exec.chatMessage("<CE>The FunCorp mode has been deactivated.")
  59.             end
  60.         end
  61.     elseif funcorp and cmd[2] then
  62.         if cmd[1] == "changesize" then
  63.             local size = cmd[#cmd]
  64.  
  65.             size = tonumber(size) or (size == "off" and 1)
  66.             if not size then
  67.                 return tfm.exec.chatMessage("<V>[•] <BL>Invalid size.", playerName)
  68.             end
  69.             size = (size < .1 and .1 or size > 5 and 5 or size)
  70.  
  71.             if cmd[2] == "*" then
  72.                 for player in next, tfm.get.room.playerList do
  73.                     tfm.exec.changePlayerSize(player, size)
  74.                 end
  75.                 tfm.exec.chatMessage("<V>[•] <BL>All the players now have " .. (size == 1 and "their regular size." or ("the size " .. size)), playerName)
  76.             else
  77.                 local players, counter = { }, 0
  78.                 for i = 2, #cmd - 1 do
  79.                     counter = counter + 1
  80.                     players[counter] = string.nick(cmd[i])
  81.                     tfm.exec.changePlayerSize(players[counter], size)
  82.                 end
  83.                 tfm.exec.chatMessage("<V>[•] <BL>The following players now have " .. (size == 1 and "their regular size" or ("the size " .. size)) .. ": <BV>" .. table.concat(players, "<BL>, <BV>"), playerName)
  84.             end
  85.         elseif cmd[1] == "colornick" then
  86.             if not cmd[3] then
  87.                 owners[playerName] = cmd[2]
  88.                 return ui.showColorPicker(0, playerName, 1, "Select a color")
  89.             end
  90.        
  91.             local off, color = cmd[#cmd] == "off"
  92.             if not off then
  93.                 if string.find(cmd[#cmd], '#') then
  94.                     cmd[#cmd] = tonumber(string.sub(cmd[3], 2), 16)
  95.                 end
  96.  
  97.                 if not cmd[#cmd] then
  98.                     return tfm.exec.chatMessage("<V>[•] <BL>Invalid color.", playerName)
  99.                 end
  100.  
  101.                 color = string.format("%x", cmd[#cmd])
  102.             end
  103.            
  104.             if cmd[2] == "*" then
  105.                 for player in next, tfm.get.room.playerList do
  106.                     tfm.exec.setNameColor(player, (not off and cmd[#cmd] or false))
  107.                 end
  108.  
  109.                 if off then
  110.                     tfm.exec.chatMessage("<V>[•] <BL>All the nickname colors have been removed.", playerName)
  111.                 else
  112.                     tfm.exec.chatMessage("<V>[•] <BL>All the players now have the nickname color <font color='#" .. color .. "'>0x" .. color .. "</font>.", playerName)
  113.                 end
  114.             else
  115.                 local players, counter = { }, 0
  116.                 for i = 2, #cmd - 1 do
  117.                     counter = counter + 1
  118.                     players[counter] = string.nick(cmd[i])
  119.                     tfm.exec.setNameColor(players[counter], (not off and cmd[#cmd] or false))
  120.                 end
  121.  
  122.                 if off then
  123.                     tfm.exec.chatMessage("<V>[•] <BL>Nickname colors removed from players: <BV>" .. table.concat(players, "<BL>, <BV>"), playerName)
  124.                 else
  125.                     tfm.exec.chatMessage("<V>[•] <BL>New nickname color <font color='#" .. color .. "'>(0x" .. color .. ")</font> for players: <BV>" .. table.concat(players, "<BL>, <BV>"), playerName)
  126.                 end
  127.             end
  128.         elseif cmd[1] == "linkmice" then
  129.             local off = cmd[#cmd] == "off"
  130.  
  131.             if cmd[2] == "*" then
  132.                 local lastPlayer
  133.                 for player in next, tfm.get.room.playerList do
  134.                     if lastPlayer then
  135.                         tfm.exec.linkMice(player, lastPlayer, not off)
  136.                     end
  137.                     lastPlayer = player
  138.                 end
  139.                
  140.                 if off then
  141.                     tfm.exec.chatMessage("<V>[•] <BL>All the links have been removed.", playerName)
  142.                 else
  143.                     tfm.exec.chatMessage("<V>[•] <BL>All the players are now linked.", playerName)
  144.                 end
  145.             else
  146.                 if not cmd[(off and 4 or 3)] then
  147.                     return tfm.exec.chatMessage("<V>[•] <BL>There must be at least two players in order to " .. (off and "unlink" or "link") .. " them.", playerName)
  148.                 end
  149.  
  150.                 local players, counter, lastPlayer = { }, 0
  151.                 for i = 2, #cmd - (off and 1 or 0) do
  152.                     counter = counter + 1
  153.                     players[counter] = string.nick(cmd[i])
  154.                     if lastPlayer then
  155.                         tfm.exec.linkMice(players[counter], lastPlayer, not off)
  156.                     end
  157.                     lastPlayer = players[counter]
  158.                 end
  159.  
  160.                 if off then
  161.                     tfm.exec.chatMessage("<V>[•] <BL>The links involving the following players have been removed: <BV>" .. table.concat(players, "<BL>, <BV>"), playerName)
  162.                 else
  163.                     tfm.exec.chatMessage("<V>[•] <BL>The following players now linked: <BV>" .. table.concat(players, "<BL>, <BV>"), playerName)
  164.                 end
  165.             end
  166.         elseif cmd[1] == "meep" then
  167.             local off = cmd[#cmd] == "off"
  168.  
  169.             if cmd[2] == "*" then
  170.                 for player in next, tfm.get.room.playerList do
  171.                     tfm.exec.giveMeep(player, not off)
  172.                 end
  173.  
  174.                 if off then
  175.                     tfm.exec.chatMessage("<V>[•] <BL>All the meep powers have been removed.", playerName)
  176.                 else
  177.                     tfm.exec.chatMessage("<V>[•] <BL>Meep powers given to all players in the room.", playerName)
  178.                 end
  179.             else
  180.                 local players, counter = { }, 0
  181.                 for i = 2, #cmd - (off and 1 or 0) do
  182.                     counter = counter + 1
  183.                     players[counter] = string.nick(cmd[i])
  184.                     tfm.exec.giveMeep(players[counter], not off)
  185.                 end
  186.  
  187.                 if off then
  188.                     tfm.exec.chatMessage("<V>[•] <BL>Meep powers removed from players: <BV>" .. table.concat(players, "<BL>, <BV>"), playerName)
  189.                 else
  190.                     tfm.exec.chatMessage("<V>[•] <BL>Meep powers given to players: <BV>" .. table.concat(players, "<BL>, <BV>"), playerName)
  191.                 end
  192.             end
  193.         elseif cmd[1] == "np" then
  194.             tfm.exec.newGame(cmd[2])
  195.         elseif cmd[1] == "npp" then
  196.             nextMap = cmd[2]
  197.             tfm.exec.disableAutoNewGame()
  198.             tfm.exec.chatMessage("<V>[•] <BL>Next map: " .. tostring(nextMap), playerName)
  199.         elseif cmd[1] == "transformation" then
  200.             local off = cmd[#cmd] == "off"
  201.  
  202.             if cmd[2] == "*" then
  203.                 for player in next, tfm.get.room.playerList do
  204.                     tfm.exec.giveTransformations(player, not off)
  205.                 end
  206.  
  207.                 if off then
  208.                     tfm.exec.chatMessage("<V>[•] <BL>All the transformations powers have been removed.", playerName)
  209.                 else
  210.                     tfm.exec.chatMessage("<V>[•] <BL>Transformations powers given to all players in the room.", playerName)
  211.                 end
  212.             else
  213.                 local players, counter = { }, 0
  214.                 for i = 2, #cmd - (off and 1 or 0) do
  215.                     counter = counter + 1
  216.                     players[counter] = string.nick(cmd[i])
  217.                     tfm.exec.giveTransformations(players[counter], not off)
  218.                 end
  219.  
  220.                 if off then
  221.                     tfm.exec.chatMessage("<V>[•] <BL>Transformations powers removed from players: <BV>" .. table.concat(players, "<BL>, <BV>"), playerName)
  222.                 else
  223.                     tfm.exec.chatMessage("<V>[•] <BL>Transformations powers given to players: <BV>" .. table.concat(players, "<BL>, <BV>"), playerName)
  224.                 end
  225.             end
  226.         end
  227.     end
  228. end
  229.  
  230. eventColorPicked = function(id, playerName, color)
  231.     eventChatCommand(playerName, "colornick " .. tostring(owners[playerName]) .. " " .. color)
  232.     owners[playerName] = true
  233. end
  234.  
  235. eventNewGame = function()
  236.     if nextMap then
  237.         nextMap = nil
  238.         tfm.exec.disableAutoNewGame(false)
  239.     end
  240.  
  241.     local counter = 0
  242.     for _ in next, tfm.get.room.playerList do
  243.         counter = counter + 1
  244.     end
  245.     miceAlive = counter
  246. end
  247.  
  248. local tentatives = 0
  249. eventLoop = function(_, remainingTime)
  250.     if nextMap and (remainingTime <= 500 or miceAlive <= 0) then
  251.         tfm.exec.newGame(nextMap)
  252.         tentatives = tentatives + 1
  253.  
  254.         if tentatives == 5 then
  255.             eventNewGame()
  256.         end
  257.     end
  258. end
  259.  
  260. eventPlayerDied = function()
  261.     miceAlive = miceAlive - 1
  262. end
  263.  
  264. eventPlayerWon = function()
  265.     miceAlive = miceAlive - 1
  266. end
  267.  
  268. eventPlayerLeft = function()
  269.     local counter = 0
  270.     for _, data in next, tfm.get.room.playerList do
  271.         if not data.isDead then
  272.             counter = counter + 1
  273.         end
  274.     end
  275.     miceAlive = counter
  276. end
  277.  
  278. system.disableChatCommandDisplay()
  279. eventNewGame()
  280.  
  281. local info = string.match(tfm.get.room.name, "#funcorp0(.+)")
  282. if info then
  283.     string.gsub(info, "%S+", function(value)
  284.         owners[string.nick(value)] = true
  285.     end)
  286. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement