Advertisement
Bolodefchoco_LUAXML

[Game] Cannonup

Sep 16th, 2017
638
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 34.15 KB | None | 0 0
  1. --Creator: Bolodefchoco
  2. --Made in: 06/02/2017
  3. --Last update: 16/09/2017
  4.  
  5. --[[ Module ]]--
  6. local module = {
  7.     _VERSION = "1",
  8.     _NAME = "cannonup",
  9.     _STATUS = "semi-official",
  10.     _AUTHOR = "Bolodefchoco",
  11.     _LICENSE = [[
  12.         MIT LICENSE
  13.        
  14.         Copyright (c) 2017 @Transformice + @Bolodefchoco
  15.        
  16.         Permission is hereby granted, free of charge, to any person obtaining
  17.         a copy of this software and associated documentation files (the
  18.         "Software"), to deal in the Software without restriction, including
  19.         without limitation the rights to use, copy, modify, merge, and to
  20.         permit persons to whom the Software is furnished to do so, subject to
  21.         the following conditions:
  22.  
  23.         The above copyright notice and this permission notice shall be included
  24.         in all copies or substantial portions of the Software.
  25.  
  26.         THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
  27.         OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF FITNESS FOR
  28.         A PARTICULAR PURPOSE AND NONINFRINGEMENT.
  29.         IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
  30.         CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
  31.         TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
  32.         SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  33.     ]],
  34.     _FREEACCESS = { -- Verified players
  35.         -- 3 : Commands + Room admin + Debug
  36.         Bolodefchoco = 3,
  37.         Trumpuke = 3,
  38.         -- 2 : Commands
  39.         Bodykudo = 2,
  40.         Error_404 = 2,
  41.         Jordynl = 2,
  42.         Laagaadoo = 2,
  43.         Mescouleur = 2,
  44.         Sebafrancuz = 2,
  45.         Tocutoeltuco = 2,
  46.         -- 1 : Some commands
  47.         Abdeltif = 1,
  48.         Animjarcanin = 1,
  49.         Artinoe = 1,
  50.         Atinesta = 1,
  51.         Auroraclears = 1,
  52.         Bapereira = 1,
  53.         Barberserk = 1,
  54.         Bataatiinha = 1,
  55.         Bellaxo = 1,
  56.         Bibsho = 1,
  57.         Bielbateriax = 1,
  58.         Bjikata = 1,
  59.         Bruniinhoowx = 1,
  60.         Byontr = 1,
  61.         Caiolopelope = 1,
  62.         Chocodivo = 1,
  63.         Claumiau = 1,
  64.         Connow = 1,
  65.         Daelea = 1,
  66.         Distances = 1,
  67.         Drescen = 1,
  68.         Ekull = 1,
  69.         Exsilium = 1,
  70.         Flindix = 1,
  71.         Gemalugeter = 1,
  72.         Grastfetry = 1,
  73.         Grincreep = 1,
  74.         Ikkemon = 1,
  75.         Jotatavo = 1,
  76.         Kimsterjay = 1,
  77.         Kingtenso = 1,
  78.         Lebluemice = 1,
  79.         Lucasrslv = 1,
  80.         Mcqv = 1,
  81.         Miyakogotoku = 1,
  82.         Mousetat = 1,
  83.         Mquk = 1,
  84.         Myelou = 1,
  85.         Nedior = 1,
  86.         Nlff = 1,
  87.         Okpatinhos = 1,
  88.         Pjfsamora = 1,
  89.         Prysmos = 1,
  90.         Reshman = 1,
  91.         Rianmojang1 = 1,
  92.         Rosianna_rabbit = 1,
  93.         Ruamorangos = 1,
  94.         Sammynya = 1,
  95.         Squalleze = 1,
  96.         Tdft = 1,
  97.         Thegbc = 1,
  98.         Tockego = 1,
  99.         Treasuredsoul = 1,
  100.         Victorruanpk = 1,
  101.         Viniciusdara = 1,
  102.         Vinitexeira = 1,
  103.         Xfelrat = 1,
  104.         Xorcist = 1,
  105.         Yuir = 1,
  106.         Zacriker = 1,
  107.         Zippydoodah = 1,
  108.         Zagear = 1,
  109.         Zombiewd = 1,
  110.     },
  111. }
  112.  
  113. --[[ Optimization ]]--
  114.   --[[ String ]]--
  115. local stringlen,stringfind,stringgmatch,stringbyte,stringdump,stringreverse,stringupper,stringformat,stringrep,stringlower,stringsub,stringgsub,stringmatch,stringchar = string.len,string.find,string.gmatch,string.byte,string.dump,string.reverse,string.upper,string.format,string.rep,string.lower,string.sub,string.gsub,string.match,string.char
  116.   --[[ Math ]]--
  117. local mathdeg,mathfmod,mathrandom,mathasin,mathmax,mathmodf,mathfloor,mathcosh,mathldexp,mathatan2,mathpow,mathrandomseed,mathfrexp,mathabs,mathtanh,mathacos,mathlog,mathtan,mathmin,mathceil,mathsinh,mathsqrt,mathhuge,mathrad,mathsin,mathexp,mathcos,mathatan,mathpi = math.deg,math.fmod,math.random,math.asin,math.max,math.modf,math.floor,math.cosh,math.ldexp,math.atan2,math.pow,math.randomseed,math.frexp,math.abs,math.tanh,math.acos,math.log,math.tan,math.min,math.ceil,math.sinh,math.sqrt,math.huge,math.rad,math.sin,math.exp,math.cos,math.atan,math.pi
  118.   --[[ Table ]]--
  119. local tablepack,tableforeachi,tableforeach,tableremove,tableinsert,tableunpack,tableconcat,tablesort = table.pack,table.foreachi,table.foreach,table.remove,table.insert,table.unpack,table.concat,table.sort
  120.  
  121. --[[ API ]]--
  122.     --[[ Control ]]--
  123. system.newGameTimer = 0
  124. system.officialMode = {"",""}
  125. system.playerMessage = ""
  126. system.setAdmins = function()
  127.     local out = {}
  128.     for k,v in next,module._FREEACCESS do
  129.         if v > 2 then
  130.             out[k] = true
  131.         end
  132.     end
  133.     return out
  134. end
  135.     --[[ Improvements ]]--
  136. tableconcat = function(list,sep,f,i,j)
  137.     local txt = ""
  138.     sep = sep or ""
  139.     i,j = i or 1,j or #list
  140.     for k,v in next,list do
  141.         if type(k) ~= "number" and true or (k >= i and k <= j) then
  142.             txt = txt .. (f and f(k,v) or v) .. sep
  143.         end
  144.     end
  145.     return stringsub(txt,1,-1-#sep)
  146. end
  147. do
  148.     local newGame = tfm.exec.newGame
  149.     tfm.exec.newGame = function(code)
  150.         if os.time() > system.newGameTimer then
  151.             system.newGameTimer = os.time() + 6000
  152.             newGame(code or "#" .. tablerandom({0,0,0,0,1,1,1,4,5,6,7,8,9,1,4,5,6,7,8,9,0}))
  153.             return true
  154.         end
  155.         return false
  156.     end
  157.    
  158.     local addImage = tfm.exec.addImage
  159.     local removeImage = tfm.exec.removeImage
  160.     tfm.exec.addImage = function(...)
  161.         local id = addImage(...)
  162.         if id then
  163.             system.objects.image[id] = true
  164.         end
  165.         return id or -1
  166.     end
  167.     tfm.exec.removeImage = function(id)
  168.         removeImage(id)
  169.         if system.objects.image[id] then
  170.             system.objects.image[id] = nil
  171.         end
  172.     end
  173.    
  174.     local addTextArea = ui.addTextArea
  175.     ui.addTextArea = function(id,...)
  176.         addTextArea(id,...)
  177.         if not system.objects.textarea[id] then
  178.             system.objects.textarea[id] = true
  179.         end
  180.     end
  181.    
  182.     local chatMessage = tfm.exec.chatMessage
  183.     tfm.exec.chatMessage = function(txt,n)
  184.         txt = tostring(txt)
  185.         if #txt > 1000 then
  186.             local total = 0
  187.             while #txt > total do
  188.                 chatMessage(stringsub(txt,total,total + 1000),n)
  189.                 total = total + 1001
  190.             end
  191.         else
  192.             chatMessage(txt,n)
  193.         end
  194.     end
  195.    
  196.     local loadPlayerData = system.loadPlayerData
  197.     system.loadPlayerData = function(n)
  198.         if module._STATUS == "official" then
  199.             return loadPlayerData(n)
  200.         else
  201.             if _G["eventPlayerDataLoaded"] then
  202.                 eventPlayerDataLoaded(n,"")
  203.             end
  204.             return true
  205.         end
  206.     end
  207.    
  208.     local savePlayerData = system.savePlayerData
  209.     system.savePlayerData = function(n,data)
  210.         if module._STATUS == "official" then
  211.             savePlayerData(n,data)
  212.             return true
  213.         else
  214.             return false
  215.         end
  216.     end
  217. end
  218.     --[[ Room ]]--
  219. system.isRoom = stringbyte(tfm.get.room.name,2) ~= 3
  220. system.roomAdmins = system.setAdmins()
  221. system.miscAttrib = 0
  222. system.roomNumber,system.roomAttributes = (function()
  223.     if system.isRoom then
  224.         local number,attribute = stringmatch(tfm.get.room.name,"%*?#"..module._NAME.."(%d+)(.*)")
  225.         return tonumber(number) or 0,attribute or ""
  226.     else
  227.         return 0,""
  228.     end
  229. end)()
  230. system.roomLanguage = ""
  231.     --[[ Player ]]--
  232. system.isPlayer = function(n)
  233.     --[[
  234.         The player must not be a souris;
  235.         The player must have played Transformice for at least 5 days
  236.     ]]
  237.     return tfm.get.room.playerList[n] and stringsub(n,1,1) ~= "*" and tfm.get.room.playerList[n].registrationDate and (os.time() - (tfm.get.room.playerList[n].registrationDate or 0) >= 432e6) or false
  238. end
  239. system.players = function(alivePlayers)
  240.     local alive,total = 0,0
  241.     if alivePlayers then
  242.         alive = {}
  243.     end
  244.     for k,v in next,tfm.get.room.playerList do
  245.         if system.isPlayer(k) then
  246.             if not v.isDead and not v.isVampire then
  247.                 if alivePlayers then
  248.                     alive[#alive + 1] = k
  249.                 else
  250.                     alive = alive + 1
  251.                 end
  252.             end
  253.             total = total + 1
  254.         end
  255.     end
  256.     if alivePlayers then
  257.         return alive
  258.     else
  259.         return alive,total
  260.     end
  261. end
  262.     --[[ System ]]--
  263. events = {}
  264. currentTime,leftTime = 0,0
  265. system.loadTable = function(s)
  266.     -- "a.b.c.1" returns a[b][c][1]
  267.     local list
  268.     for tbl in stringgmatch(s,"[^%.]+") do
  269.         tbl = tonumber(tbl) and tonumber(tbl) or tbl
  270.         list = (list and list[tbl] or _G[tbl])
  271.     end
  272.     return list
  273. end
  274. system.getTranslation = function(index,n)
  275.     local t = stringformat("mode.%s.translations.%s.%s",system.gameMode,(n and mode[system.gameMode].info[n].langue or mode[system.gameMode].langue),index)
  276.     return system.loadTable(t) or system.loadTable(stringgsub(t,"translations%..-%.",function() return "translations.en." end))
  277. end
  278. system.looping = function(f,tick)
  279.     local s = 1000 / tick
  280.     local t = {}
  281.    
  282.     local fooTimer = function()
  283.         t[#t+1] = system.newTimer(f,1000,true)
  284.     end
  285.     for timer = 0,1000 - s,s do
  286.         system.newTimer(fooTimer,1000 + timer,false)
  287.     end
  288.     return t
  289. end
  290.     --[[ Interface ]]--
  291. ui.banner = function(image,aX,aY,n,time)
  292.     time = time or 5
  293.     axis = axis or {100,100}
  294.    
  295.     local img = tfm.exec.addImage(image .. ".png","&0",aX,aY,n)
  296.     system.newTimer(function()
  297.         tfm.exec.removeImage(img)
  298.     end,time * 1000,false)
  299. end
  300.     --[[ Math ]]--
  301. mathisNegative = function(x,iN,iP)
  302.     iN = iN == nil and x or iN
  303.     iP = iP == nil and x or iP
  304.     return (x<0 and iN or iP)
  305. end
  306. mathpercent = function(x,y,v)
  307.     v = (v or 100)
  308.     local m = x/y * v
  309.     return mathmin(m,v)
  310. end
  311. mathpythag = function(x1,y1,x2,y2,range)
  312.     return (x1-x2)^2 + (y1-y2)^2 <= (range^2)
  313. end
  314. mathsetLim = function(value,min,max)
  315.     return mathmax(min,mathmin(max,value))
  316. end
  317.     --[[ String ]]--
  318. stringsplit = function(value,pattern,f)
  319.     local out = {}
  320.     for v in stringgmatch(value,pattern) do
  321.         out[#out + 1] = (f and f(v) or v)
  322.     end
  323.     return out
  324. end
  325. stringnick = function(player)
  326.     return stringgsub(stringlower(player),"%a",stringupper,1)
  327. end
  328. stringtrim = function(s)
  329.     return (stringgsub(s,"^%s*(.-)%s*$","%1"))
  330. end
  331.     --[[ Table ]]--
  332. tablefind = function(list,value,index,f)
  333.     for k,v in next,list do
  334.         local i = (type(v) == "table" and index and v[index] or v)
  335.         if (f and f(i) or i) == value then
  336.             return true,k
  337.         end
  338.     end
  339.     return false,0
  340. end
  341. tableturnTable = function(x)
  342.     return (type(x)=="table" and x or {x})
  343. end
  344. tablerandom = function(t)
  345.     return (type(t) == "table" and t[mathrandom(#t)] or mathrandom())
  346. end
  347. tableshuffle = function(t)
  348.     local randomized = {}
  349.     for v = 1,#t do
  350.         tableinsert(randomized,mathrandom(#randomized),t[v])
  351.     end
  352.     return randomized
  353. end
  354. tablemerge = function(this,src)
  355.     for k,v in next,src do
  356.         if this[k] then
  357.             if type(v) == "table" then
  358.                 this[k] = tableturnTable(this[k])
  359.                 tablemerge(this[k],v)
  360.             else
  361.                 this[k] = this[k] or v
  362.             end
  363.         else
  364.             this[k] = v
  365.         end
  366.     end
  367. end
  368.     --[[ Others ]]--
  369. deactivateAccents=function(str)
  370.     local letters = {a = {"á","â","à","Ã¥","ã","ä"},e = {"é","ê","è","ë"},i = {"í","î","ì","ï"},o = {"ó","ô","ò","õ","ö"},u = {"ú","û","ù","ü"}}
  371.     for k,v in next,letters do
  372.         for i = 1,#v do
  373.             str = stringgsub(str,v[i],tostring(k))
  374.         end
  375.     end
  376.     return str
  377. end
  378. normalizeTime = function(time)
  379.     return mathfloor(time) + ((time - mathfloor(time)) >= .5 and .5 or 0)
  380. end
  381. disableChatCommand = function(command,...)
  382.     for k,v in next,{command,...} do
  383.         system.disableChatCommandDisplay(v,true)
  384.         system.disableChatCommandDisplay(stringlower(v),true)
  385.         system.disableChatCommandDisplay(stringupper(v),true)
  386.     end
  387. end
  388. normalizeTranslation = function()
  389.     local t = mode[system.gameMode].translations
  390.  
  391.     if mode[system.gameMode].langue == "" then
  392.         mode[system.gameMode].translations.pt = mode[system.gameMode].translations.br
  393.        
  394.         -- Sets the main language according to the community
  395.         local p = {system.roomLanguage,tfm.get.room.community}
  396.         for i = 1,#p do
  397.             if mode[system.gameMode].translations[p[i]] then
  398.                 mode[system.gameMode].langue = p[i]
  399.             end
  400.         end
  401.     end
  402.  
  403.     for k,v in next,t do
  404.         if k ~= "en" then
  405.             tablemerge(v,t.en)
  406.         end
  407.     end
  408. end
  409. normalizeNumber = function(number,sep)
  410.     sep = sep or " "
  411.     number = tostring(mathfloor(number))
  412.     number = stringgsub(number,"E(%d+)",function(cn) -- e5 = 00000
  413.         return stringrep("0",tonumber(cn))
  414.     end)
  415.     number = stringgsub(stringreverse(number),"(...)",function(c)
  416.         return c .. sep
  417.     end)
  418.     return stringreverse(number)
  419. end
  420. pairsByIndexes = function(list,f)
  421.     local out = {}
  422.     for index in next,list do
  423.         out[#out + 1] = index
  424.     end
  425.     tablesort(out,f)
  426.    
  427.     local i = 0
  428.     return function()
  429.         i = i + 1
  430.         if out[i] == nil then
  431.             return nil
  432.         else
  433.             return out[i],list[out[i]]
  434.         end
  435.     end
  436. end
  437.     --[[ XML ]]--
  438. xml = {}
  439. xml.parse = function(currentXml)
  440.     currentXml = stringmatch(currentXml,"<P (.-)/>") or ""
  441.     local out = {}
  442.     for tag,_,value in stringgmatch(currentXml,"([%-%w]+)=([\"'])(.-)%2") do
  443.         out[tag] = value
  444.     end
  445.     return out
  446. end
  447. xml.attribFunc = function(currentXml,funcs)
  448.     local attributes = xml.parse(currentXml)
  449.     for k,v in next,funcs do
  450.         if attributes[v.attribute] then
  451.             v.func(attributes[v.attribute])
  452.         end
  453.     end
  454. end
  455. xml.addAttrib = function(currentXml,out,launch)
  456.     local parameters = stringmatch(currentXml,"<P (.-)/>") or ""
  457.     for k,v in next,out do
  458.         if not stringfind(parameters,v.tag) then
  459.             currentXml = stringgsub(currentXml,"<P (.-)/>",function(attribs)
  460.                 return stringformat("<P %s=\"%s\" %s/>",v.tag,v.value,attribs)
  461.             end)
  462.         end
  463.     end
  464.     if launch then
  465.         tfm.exec.newGame(currentXml)
  466.     else
  467.         return currentXml
  468.     end
  469. end
  470. xml.getCoordinates = function(s)
  471.     if stringfind(s,";") then
  472.         local x,y
  473.         local axis,value = stringmatch(s,"(%a);(%d+)")
  474.         value = tonumber(value)
  475.         if value then
  476.             if axis == "x" then x = value else y = value end
  477.         end
  478.         return x or 0,y or 0
  479.     else
  480.         local pos = {}
  481.         for x,y in stringgmatch(s,"(%d+) ?, ?(%d+)") do
  482.             pos[#pos+1] = {x = x,y = y}
  483.         end
  484.         return pos
  485.     end
  486. end
  487.     --[[ Color ]]--
  488. color = {
  489.     hexToRgb = function(hex)
  490.         local h = stringformat("%06x",hex)
  491.         return tonumber("0x"..stringsub(h,1,2)),tonumber("0x"..stringsub(h,3,4)),tonumber("0x"..stringsub(h,5,6))
  492.     end,
  493.     rgbToHsl = function(r,g,b)
  494.         r,g,b = r/255,g/255,b/255
  495.  
  496.         local max,min = mathmax(r,g,b),mathmin(r,g,b)
  497.         local h,s,l
  498.  
  499.         h = (max + min) / 2
  500.         s,l = h,h
  501.  
  502.         if max == min then
  503.             h,s = 0,0
  504.         else
  505.             local d = max - min
  506.            
  507.             local s = l > .5 and (d/(2 - max - min)) or (d/(max + min))
  508.            
  509.             if max == r then
  510.                 h = (g-b)/d
  511.                 if g < b then
  512.                     h = h + 6
  513.                 end
  514.             elseif max == g then
  515.                 h = (b-r)/d + 2
  516.             elseif max == b then
  517.                 h = (r-g)/d + 4
  518.             end
  519.             h = h/6
  520.         end
  521.  
  522.         return {h=h,s=s,l=l}
  523.     end,
  524.     hslToRgb = function(h,s,l)
  525.         local r,g,b
  526.  
  527.         if s == 0 then
  528.             r,g,b = l,l,l
  529.         else
  530.             local hueToRgb = function(p,q,t)
  531.                 if t < 0 then
  532.                     t = t + 1
  533.                 end
  534.                 if t > 1 then
  535.                     t = t - 1
  536.                 end
  537.                 if t < 1/6 then
  538.                     return p + (q - p) * 6 * t
  539.                 end
  540.                 if t < 1/2 then
  541.                     return q
  542.                 end
  543.                 if t < 2/3 then
  544.                     return p + (q - p) * (2/3 - t) * 6
  545.                 end
  546.                 return p
  547.             end
  548.  
  549.             local q = l < .5 and (l * (1 + s)) or (l + s - l * s)
  550.             local p = 2 * l - q
  551.  
  552.             r = hueToRgb(p,q,h + 1/3)
  553.             g = hueToRgb(p,q,h)
  554.             b = hueToRgb(p,q,h - 1/3)
  555.         end
  556.  
  557.         return r * 255,g * 255,b * 255
  558.     end,
  559.     rgbToHex = function(r,g,b)
  560.         return tonumber(stringformat('%02x%02x%02x',r,g,b),16)
  561.     end,
  562.     YELLOW = 0xF9EC27,
  563.     RED = 0xF94226,
  564.     LIGHT_RED = 0xD1605D,
  565.     BLUE = 0x34A4E5,
  566.     DEEP_BLUE = 0x4F7F9A,
  567.     DARK_BLUE = 0x2D80AF,
  568.     GRAY = 0x969696,
  569.     SALMON = 0xAC6C64,
  570.     BROWN = 0x89635A,
  571.     BEIGE = 0x937A53,
  572.     TURQUOISE = 0x59D1C8,
  573.     ROSE = 0x816669,
  574.     MOSS_GREEN = 0x689636,
  575. }
  576.  
  577. --[[ GameMode ]]--
  578. system.submodes = {}
  579.  
  580. system.gameMode = module._NAME
  581. system.modeChanged = os.time() + 1000
  582.  
  583. system.getGameMode = function(value,notFirst)
  584.     local found,submode = tablefind(system.submodes,stringlower(value),nil,stringlower)
  585.     if found then
  586.         system.gameMode = system.submodes[submode]
  587.        
  588.         if notFirst then
  589.             eventModeChanged()
  590.         end
  591.        
  592.         system.modeChanged = os.time() + 1000
  593.     end
  594.     return found
  595. end
  596.  
  597. --[[ Modes ]]--
  598. mode = setmetatable({},{
  599.     __newindex = function(list,key,value)
  600.         rawset(list,key,setmetatable(value,{
  601.             __index = function(nList,nKey)
  602.                 if nKey == "langue" then
  603.                     return "en"
  604.                 end
  605.             end
  606.         }))
  607.         system.submodes[#system.submodes+1] = key
  608.     end
  609. })
  610.  
  611. --[[ Cannonup ]]--
  612. mode.cannonup = {
  613.     -- Translations
  614.     translations = {
  615.         en = {
  616.             -- Init
  617.             welcome = "Welcome to #cannonup. Your aim is to be the survivor! <VP>Take care, watermelons are dangerous!\n\t<J>Report any issue to Bolodefchoco.",
  618.  
  619.             -- Info
  620.             nowinner = "No one won!",
  621.            
  622.             -- Simple words
  623.             won = "won!",
  624.            
  625.             -- Profile
  626.             profile = "Rounds : <V>%d</V>\nCheeses : <V>%d</V>\n\nDeaths : <V>%d</V>",
  627.         },
  628.         br = {
  629.             welcome = "Bem-vindo ao #cannonup. Seu objetivo é ser o sobrevivente! <VP>Tome cuidado, melancias são perigosas!\n\t<J>Reporte qualquer problema para Bolodefchoco.",
  630.        
  631.             nowinner = "Ninguém ganhou!",
  632.        
  633.             won = "venceu!",
  634.            
  635.             profile = "Rodadas : <V>%d</V>\nQueijos : <V>%d</V>\n\nMortes : <V>%d</V>",
  636.         },
  637.     },
  638.     langue = "",
  639.     --[[ Data ]]--
  640.     info = {},
  641.     --[[ Maps ]]--
  642.     maps = {3746497,6001536,3666224,4591929,"#10","#10","#10","#10","#10","#10","#10","#10","#10"},
  643.     --[[ Settings ]]--
  644.     -- Status
  645.     isRunning = true,
  646.     totalPlayers = 0,
  647.     soloGame = false,
  648.     -- New Game
  649.     cannon = {
  650.         x = 0,
  651.         y = 0,
  652.         time = 3,
  653.         amount = 1,
  654.         speed = 20,
  655.     },
  656.     canMessage = false,
  657.     currentXml = -1,
  658.     toDespawn = {},
  659.     alivePlayers = {},
  660.     --[[ System ]]--
  661.     -- Cannon
  662.     getCannon = function()
  663.         local currentMonth = tonumber(os.date("%m"))
  664.        
  665.         if currentMonth == 12 then
  666.             return 1703 -- Christmas [Ornament]
  667.         elseif currentMonth == 10 then
  668.             return tablerandom({17,1701,1702}) -- Halloween [Normal, Glass, Lollipop]
  669.         elseif currentMonth == 5 and tonumber(os.date("%d")) < 11 then
  670.             return 1704 -- Transformice's Birthday [Shaman]
  671.         elseif currentMonth == 7 then
  672.             return tablerandom({17,1705,1706}) -- Vacations [Normal, Apple, Watermellon]
  673.         else
  674.             return tablerandom({17,17,17,1706}) -- Standard
  675.         end
  676.     end,
  677.     -- Shoot
  678.     newCannon = function()
  679.         local alive = system.players(true)
  680.         if #alive > 0 then
  681.             local player
  682.             repeat
  683.                 player = tfm.get.room.playerList[tablerandom(alive)]
  684.             until not player.isDead
  685.            
  686.             local coordinates = {
  687.                 {player.x,mathrandom() * 700},
  688.                 {player.y,mathrandom() * 300},
  689.                 {false,false}
  690.             }
  691.            
  692.             if mode.cannonup.cannon.x ~= 0 then
  693.                 coordinates[1][2] = mode.cannonup.cannon.x
  694.                 coordinates[3][1] = true
  695.             end
  696.             if mode.cannonup.cannon.y ~= 0 then
  697.                 coordinates[2][2] = mode.cannonup.cannon.y
  698.                 coordinates[3][2] = true
  699.             end
  700.            
  701.             if not coordinates[3][2] and coordinates[2][2] > coordinates[2][1] then
  702.                 coordinates[2][2] = coordinates[2][1] - mathrandom(100) - 35
  703.             end
  704.             if not coordinates[3][1] and mathabs(coordinates[1][2] - coordinates[1][1]) > 350 then
  705.                 coordinates[1][2] = coordinates[1][1] + mathrandom(-100,100)
  706.             end
  707.            
  708.             local ang = mathdeg(mathatan2(coordinates[2][2] - coordinates[2][1],coordinates[1][2] - coordinates[1][1]))
  709.             tfm.exec.addShamanObject(0,coordinates[1][2] - (coordinates[3][1] and 0 or 10),coordinates[2][2] - (coordinates[3][2] and 0 or 10),ang + 90)
  710.            
  711.             --system.newTimer(function()
  712.                 mode.cannonup.toDespawn[#mode.cannonup.toDespawn + 1] = {tfm.exec.addShamanObject(mode.cannonup.getCannon(),coordinates[1][2],coordinates[2][2],ang - 90,mode.cannonup.cannon.speed),os.time() + 5000}
  713.             --end,mathisNegative((mode.cannonup.cannon.speed - 1) * 500,0),false)
  714.         end
  715.     end,
  716.     -- Player Update
  717.     updatePlayers = function()
  718.         local alive,total = system.players()
  719.         mode.cannonup.alivePlayers = system.players(true)
  720.         mode.cannonup.totalPlayers = total
  721.     end,
  722.     --[[ UI ]]--
  723.     uiprofile = function(p,n)
  724.         ui.addTextArea(1,"\n\n<font size='13'>\n" .. stringformat(system.getTranslation("profile"),mode.cannonup.info[p].round,mode.cannonup.info[p].victory,mode.cannonup.info[p].death),n,300,100,200,150,0x0B282E,0x1B282E,1,true)
  725.         ui.addTextArea(2,"<p align='center'><font size='20'><VP><B><a href='event:close'>"..p.."</a>",n,305,105,190,30,0x244452,0x1B282E,.4,true)
  726.     end,
  727.     --[[ Init ]]--
  728.     reset = function()
  729.         -- Data
  730.         mode.cannonup.info = {}
  731.     end,
  732.     init = function()
  733.         -- Init
  734.         for _,f in next,{"AutoShaman","AutoScore","AutoNewGame","AutoTimeLeft","PhysicalConsumables"} do
  735.             tfm.exec["disable"..f]()
  736.         end
  737.         tfm.exec.setRoomMaxPlayers(25)
  738.         --tfm.exec.newGame('<C><P /><Z><S><S L="800" o="324650" H="100" X="400" Y="400" T="12" P="0,0,0.3,0.2,0,0,0,0" /></S><D /><O /></Z></C>')
  739.    
  740.         -- Auto Admin
  741.         system.roomAdmins.Byontr = true
  742.     end,
  743.     --[[ Events ]]--
  744.     -- NewPlayer
  745.     eventNewPlayer = function(n)
  746.         if not mode.cannonup.info[n] then
  747.             mode.cannonup.info[n] = {
  748.                 round = 0,
  749.                 victory = 0,
  750.                 death = 0
  751.             }
  752.         end
  753.        
  754.         if mode.cannonup.soloGame then
  755.             mode.cannonup.updatePlayers()
  756.             if mode.cannonup.totalPlayers > 1 then
  757.                 mode.cannonup.soloGame = false
  758.                 mode.cannonup.currentXml = -1
  759.             end
  760.         end
  761.        
  762.         tfm.exec.chatMessage("<J>" .. system.getTranslation("welcome"),n)
  763.        
  764.         ui.banner("15d60d944f5",140,135,n)
  765.     end,
  766.     -- NewGame
  767.     eventNewGame = function()
  768.         ui.setMapName("#CannonUp")
  769.        
  770.         mode.cannonup.cannon = {
  771.             x = 0,
  772.             y = 0,
  773.             time = 3,
  774.             amount = ((mode.cannonup.totalPlayers - (mode.cannonup.totalPlayers % 10)) / 10) + mathsetLim(system.miscAttrib+1,1,5), -- mathmin(5,mathmax(1,system.miscAttrib+1))
  775.             speed = 20,
  776.         }
  777.  
  778.         mode.cannonup.toDespawn = {}
  779.        
  780.         if mode.cannonup.currentXml == -1 then
  781.             mode.cannonup.currentXml = 0
  782.         elseif mode.cannonup.currentXml == -2 then
  783.             mode.cannonup.currentXml = -1
  784.         end
  785.        
  786.         ui.removeTextArea(0,nil)
  787.         if mode.cannonup.isRunning then
  788.             if mode.cannonup.currentXml == 0 then
  789.                 tfm.exec.setGameTime(5)
  790.                
  791.                 mode.cannonup.currentXml = xml.addAttrib(tfm.get.room.xmlMapInfo.xml or "",{
  792.                     [1] = {
  793.                         tag = "BH",
  794.                         value = "",
  795.                     }
  796.                 },false)
  797.                 ui.addTextArea(0,"",nil,-1500,-1500,3e3,3e3,0x6A7495,0x6A7495,1,true)
  798.                
  799.                 mode.cannonup.canMessage = false
  800.             else
  801.                 tfm.exec.setGameTime(125)
  802.                 mode.cannonup.canMessage = true
  803.                
  804.                 if mode.cannonup.totalPlayers > 3 then
  805.                     for k,v in next,mode.cannonup.info do
  806.                         v.round = v.round + 1
  807.                     end
  808.                 end
  809.                
  810.                 xml.attribFunc(mode.cannonup.currentXml or "",{
  811.                     [1] = {
  812.                         attribute = "cn",
  813.                         func = function(value)
  814.                             local coord,axY = xml.getCoordinates(value)
  815.                             if type(coord) == "table" then
  816.                                 mode.cannonup.cannon.x = coord[1].x
  817.                                 mode.cannonup.cannon.y = coord[1].y
  818.                             else
  819.                                 if axY == 0 then
  820.                                     mode.cannonup.cannon.x = coord
  821.                                 else
  822.                                     mode.cannonup.cannon.y = coord
  823.                                 end
  824.                             end
  825.                         end
  826.                     },
  827.                     [2] = {
  828.                         attribute = "cheese",
  829.                         func = function()
  830.                             tableforeach(tfm.get.room.playerList,tfm.exec.giveCheese)
  831.                         end,
  832.                     },
  833.                     [3] = {
  834.                         attribute = "meep",
  835.                         func = function()
  836.                             tableforeach(tfm.get.room.playerList,tfm.exec.giveMeep)
  837.                         end,
  838.                     },
  839.                 })
  840.            
  841.                 mode.cannonup.currentXml = 0
  842.                 mode.cannonup.canMessage = true
  843.             end
  844.         else
  845.             tfm.exec.setGameTime(1e7)
  846.             mode.cannonup.currentXml = -1
  847.             mode.cannonup.canMessage = false
  848.         end
  849.     end,
  850.     -- Loop
  851.     eventLoop = function()
  852.         mode.cannonup.updatePlayers()
  853.  
  854.         if mode.cannonup.totalPlayers < 2 then
  855.             --mode.cannonup.isRunning = false
  856.             --mode.cannonup.canMessage = false
  857.             --mode.cannonup.currentXml = -2
  858.             mode.cannonup.soloGame = true
  859.         end
  860.        
  861.         if mode.cannonup.isRunning then
  862.             --else
  863.             if mode.cannonup.currentXml == -1 then
  864.                 tfm.exec.newGame(tablerandom(mode.cannonup.maps))
  865.             elseif mode.cannonup.currentXml ~= 0 then
  866.                 tfm.exec.newGame(mode.cannonup.currentXml)
  867.             else       
  868.                 if _G.leftTime < 4 or (not mode.cannonup.soloGame and #mode.cannonup.alivePlayers < 2) or #mode.cannonup.alivePlayers == 0 then
  869.                     if mode.cannonup.canMessage and not mode.cannonup.soloGame then -- and mode.cannonup.totalPlayers > 1 then
  870.                         mode.cannonup.canMessage = false
  871.                         if #mode.cannonup.alivePlayers > 0 then
  872.                             for k,v in next,mode.cannonup.alivePlayers do
  873.                                 tfm.exec.giveCheese(v)
  874.                                 tfm.exec.playerVictory(v)
  875.                                 if mode.cannonup.totalPlayers > 3 then
  876.                                     mode.cannonup.info[v].victory = mode.cannonup.info[v].victory + 1
  877.                                 end
  878.                                 tfm.exec.setPlayerScore(v,5,true)
  879.                             end
  880.                            
  881.                             tfm.exec.chatMessage("<J>" .. tableconcat(mode.cannonup.alivePlayers,"<G>, <J>") .. " <J>" .. system.getTranslation("won"))
  882.                         else
  883.                             tfm.exec.chatMessage("<J>" .. system.getTranslation("nowinner"))
  884.                         end
  885.                     end
  886.                     tfm.exec.newGame(tablerandom(mode.cannonup.maps))
  887.                 else
  888.                     if _G.currentTime > 5 and mode.cannonup.currentXml == 0 then
  889.                         if _G.currentTime % mode.cannonup.cannon.time == 0 then
  890.                             for i = 1,mode.cannonup.cannon.amount do
  891.                                 mode.cannonup.newCannon()
  892.                             end
  893.                         end
  894.                        
  895.                         if #mode.cannonup.toDespawn > 0 then
  896.                             for i = 1,#mode.cannonup.toDespawn do
  897.                                 if os.time() > mode.cannonup.toDespawn[i][2] then
  898.                                     tfm.exec.removeObject(mode.cannonup.toDespawn[i][1])
  899.                                 end
  900.                             end
  901.                         end
  902.                        
  903.                         if _G.currentTime % 20 == 0 then
  904.                             mode.cannonup.cannon.amount = ((mode.cannonup.totalPlayers - (mode.cannonup.totalPlayers % 10)) / 10) + mathsetLim(system.miscAttrib+1,1,5) --mathmin(5,mathmax(1,system.miscAttrib+1))
  905.                             mode.cannonup.cannon.speed = mode.cannonup.cannon.speed + 20
  906.                             mode.cannonup.cannon.time = mathmax(.5,mode.cannonup.cannon.time-.5)
  907.                         end
  908.                     end
  909.                 end
  910.             end
  911.         else
  912.             if mode.cannonup.currentXml == -2 then
  913.                 tfm.exec.newGame('<C><P /><Z><S><S L="800" o="324650" H="100" X="400" Y="400" T="12" P="0,0,0.3,0.2,0,0,0,0" /></S><D /><O /></Z></C>')
  914.             end
  915.        
  916.             if mode.cannonup.totalPlayers > 1 or mode.cannonup.soloGame then
  917.                 mode.cannonup.isRunning = true
  918.             end
  919.         end
  920.     end,
  921.     -- ChatCommand
  922.     eventChatCommand = function(n,c)
  923.         local p = stringsplit(c,"[^%s]+",stringlower)
  924.         if p[1] == "p" or p[1] == "profile" then
  925.             if p[2] then
  926.                 p[2] = stringnick(p[2])
  927.                 if tfm.get.room.playerList[p[2]] then
  928.                     mode.cannonup.uiprofile(p[2],n)
  929.                 end
  930.             else
  931.                 mode.cannonup.uiprofile(n,n)
  932.             end
  933.         end
  934.     end,
  935.     -- TextAreaCallback
  936.     eventTextAreaCallback = function(i,n,c)
  937.         if c == "close" then
  938.             for i = 1,2 do
  939.                 ui.removeTextArea(i,n)
  940.             end
  941.         end
  942.     end,
  943.     -- PlayerLeft
  944.     eventPlayerLeft = function()
  945.         mode.cannonup.updatePlayers()
  946.     end,
  947.     -- PlayerDied
  948.     eventPlayerDied = function(n)
  949.         mode.cannonup.info[n].death = mode.cannonup.info[n].death + 1
  950.     end,
  951. }
  952.  
  953. --[[ ModeChanged ]]--
  954. system.objects = {
  955.     image = {},
  956.     textarea = {}
  957. }
  958. eventModeChanged = function()
  959.     -- Remove content
  960.     for k in next,system.objects.image do
  961.         tfm.exec.removeImage(k)
  962.     end
  963.    
  964.     for k in next,system.objects.textarea do
  965.         ui.removeTextArea(k,nil)
  966.     end
  967.    
  968.     system.objects = {
  969.         image = {},
  970.         textarea = {}
  971.     }
  972.    
  973.     ui.addPopup(0,0,"",nil,-1500,-1500)
  974.    
  975.     -- Unbind keyboard and mouse, also normalize color name and scores
  976.     for k in next,tfm.get.room.playerList do
  977.         for i = 0,255 do
  978.             for v = 0,1 do
  979.                 system.bindKeyboard(k,i,v == 0,false)
  980.             end
  981.         end
  982.        
  983.         system.bindMouse(k,false)
  984.        
  985.         tfm.exec.setNameColor(k,-1)
  986.         tfm.exec.setPlayerScore(k,0)
  987.     end
  988.    
  989.     -- Set admin back
  990.     system.roomAdmins = system.setAdmins()
  991.    
  992.     -- Reset settings
  993.     tfm.exec.snow(0)
  994.     for k,v in next,{"AutoScore","WatchCommand","AutoNewGame","AutoShaman","AllShamanSkills","MortCommand","DebugCommand","MinimalistMode","AfkDeath","PhysicalConsumables","AutoTimeLeft"} do
  995.         tfm.exec["disable" .. v](false)
  996.     end
  997.     tfm.exec.setAutoMapFlipMode()
  998.    
  999.     tfm.exec.setRoomMaxPlayers(25)
  1000.     tfm.exec.setRoomPassword("")   
  1001. end
  1002.  
  1003. --[[ Events ]]--
  1004.     --[[ eventLoop ]]--
  1005. events.eventLoop = function(currentTime,leftTime)
  1006.     _G.currentTime = normalizeTime(currentTime / 1e3)
  1007.     _G.leftTime = normalizeTime(leftTime / 1e3)
  1008. end
  1009.     --[[ eventNewPlayer ]]--
  1010. events.eventNewPlayer = function(n)
  1011.     tfm.exec.lowerSyncDelay(n)
  1012.    
  1013.     if system.officialMode[2] ~= "" then
  1014.         tfm.exec.chatMessage(system.officialMode[2],n)
  1015.     end
  1016.    
  1017.     if system.playerMessage ~= "" then
  1018.         tfm.exec.chatMessage("<J>" .. system.playerMessage,n)
  1019.     end
  1020. end
  1021.     --[[ eventChatCommand ]]--
  1022. events.eventChatCommand = function(n,c)
  1023.     if system.isPlayer(n) then
  1024.         system.disableChatCommandDisplay(c,true)
  1025.        
  1026.         local p = stringsplit(c,"[^%s]+",stringlower)
  1027.         disableChatCommand(p[1])
  1028.    
  1029.         if module._FREEACCESS[n] then
  1030.             if p[1] == "refresh" and (module._FREEACCESS[n] > 1 or not system.isRoom) then
  1031.                 eventModeChanged()
  1032.                 system.init(true)
  1033.                 return
  1034.             end
  1035.            
  1036.             if p[1] == "room" and (module._FREEACCESS[n] > 1 or not system.isRoom) then
  1037.                 local room = tonumber(p[2]) or 0
  1038.                 if _G["eventChatCommand"] and system.roomNumber ~= room then
  1039.                     system.roomNumber = room
  1040.                     eventChatCommand(n,"refresh")
  1041.                 end
  1042.                 return
  1043.             end
  1044.            
  1045.             if p[1] == "setmisc" and p[2] and (module._FREEACCESS[n] > 1 or not system.isRoom) then
  1046.                 system.miscAttrib = tonumber(p[2]) or 0
  1047.                 system.miscAttrib = mathsetLim(system.miscAttrib,0,99)
  1048.                 if p[3] == "true" then
  1049.                     eventChatCommand(n,"refresh")
  1050.                 end
  1051.                 return
  1052.             end
  1053.            
  1054.             if p[1] == "load" and (module._FREEACCESS[n] > 2 or not system.isRoom) then
  1055.                 if os.time() > system.modeChanged and os.time() > system.newGameTimer then
  1056.                     if system.getGameMode(p[2],true) then
  1057.                         system.init(system.isRoom)
  1058.                     end
  1059.                 end            
  1060.                 return
  1061.             end
  1062.         end
  1063.        
  1064.         if p[1] == "module" then
  1065.             p[2] = stringupper(p[2] or "")
  1066.            
  1067.             if module["_" .. p[2]] then
  1068.                 if p[2] == "FREEACCESS" then
  1069.                     if p[3] then
  1070.                         p[3] = stringnick(p[3])
  1071.                         tfm.exec.chatMessage(p[3] .. " ~> " .. (module._FREEACCESS[p[3]] or 0),n)
  1072.                     else
  1073.                         tfm.exec.chatMessage(p[2] .. " : ",n)
  1074.                         for k,v in pairsByIndexes(module._FREEACCESS,function(a,b) return module._FREEACCESS[a] > module._FREEACCESS[b] end) do
  1075.                             tfm.exec.chatMessage(stringformat("%s ~> %s",k,v),n)
  1076.                         end
  1077.                     end
  1078.                 else
  1079.                     tfm.exec.chatMessage(p[2] .. " : " .. tableconcat(tableturnTable(module["_" .. p[2]]),"\n",function(k,v)
  1080.                         return v
  1081.                     end),n)
  1082.                 end
  1083.             else
  1084.                 tfm.exec.chatMessage(stringformat("VERSION : %s\nNAME : %s\nSTATUS : %s\nAUTHOR : %s\n\nMODE : %s",module._VERSION,module._NAME,module._STATUS,module._AUTHOR,system.gameMode),n)
  1085.             end
  1086.             return
  1087.         end
  1088.        
  1089.         if p[1] == "modes" then
  1090.             tfm.exec.chatMessage(tableconcat({tableunpack(system.submodes,2)},"\n",function(k,v)
  1091.                 return stringformat("~> /room #%s%s@%s#%s",module._NAME,mathrandom(0,999),n,v)
  1092.             end),n)
  1093.             return
  1094.         end
  1095.  
  1096.         if p[1] == "stop" and system.roomAdmins[n] then
  1097.             system.exit()
  1098.         end
  1099.        
  1100.         if p[1] == "admin" then
  1101.             tfm.exec.chatMessage(tableconcat(system.roomAdmins,", ",tostring),n)
  1102.             return
  1103.         end
  1104.        
  1105.         if p[1] == "adm" and p[2] and (system.roomAdmins[n] or (module._FREEACCESS[n] and module._FREEACCESS[n] > 2)) then
  1106.             if tablefind({"true","false"},p[3]) then
  1107.                 local pl = stringnick(p[2])
  1108.                 system.roomAdmins[pl] = (module._FREEACCESS[pl] and true) or p[3] == "true" or nil
  1109.             end
  1110.             return
  1111.         end
  1112.        
  1113.         if p[1] == "setroomlanguage" and p[2] and (system.roomAdmins[n] or (module._FREEACCESS[n] and module._FREEACCESS[n] > 2)) then
  1114.             if mode[system.gameMode].translations[p[2]] then
  1115.                 system.roomLanguage = p[2]
  1116.                 mode[system.gameMode].langue = system.roomLanguage
  1117.             end
  1118.             return
  1119.         end
  1120.        
  1121.         if p[1] == "me" then
  1122.             local commands = {
  1123.                 [0] = {},
  1124.                 [1] = {"!refresh (tribe house)","!setMisc [number] [refresh] (tribe house)","!room [number] (tribe house)","!load [mode] (tribe house)"},
  1125.                 [2] = {"!refresh","!setMisc [number] [refresh]","!room [number]","!load [mode] (tribe house)"},
  1126.                 [3] = {"!refresh","!setMisc [number] [refresh]","!room [number]","!load [mode]"}
  1127.             }
  1128.            
  1129.             local access = module._FREEACCESS[n] or 0
  1130.            
  1131.             if system.roomAdmins[n] then
  1132.                 for k,v in next,{"!stop","!adm [playerName] [true/false]","!setRoomLanguage [language]"} do
  1133.                     commands[access][#commands[access] + 1] = v
  1134.                 end
  1135.             end
  1136.            
  1137.             tfm.exec.chatMessage(stringformat("@%s\nACCESS : %s\nROOM ADMIN : %s\n\n~> Commands: %s",n,access,tostring(not not system.roomAdmins[n]),tableconcat(commands[access],"; ")),n)
  1138.             return
  1139.         end
  1140.     end
  1141. end
  1142.  
  1143. --[[ RoomSettings ]]--
  1144. system.roomSettings = {
  1145.     -- 0 = Only the first value
  1146.     -- 1 = All the text
  1147.     ["@"] = {0,function(n)
  1148.         if n and #n > 2 then
  1149.             system.roomAdmins[stringnick(n)] = true
  1150.         end
  1151.     end},
  1152.     ["*"] = {0,function(id)
  1153.         system.miscAttrib = tonumber(id) or 1
  1154.         system.miscAttrib = mathsetLim(system.miscAttrib,1,99)
  1155.     end},
  1156.     ["#"] = {0,function(name)
  1157.         if name then
  1158.             local game = system.getGameMode(name)
  1159.             if not game then
  1160.                 system.gameMode = module._NAME
  1161.             end
  1162.         end
  1163.     end},
  1164.     [":"] = {1,function(text)
  1165.         if text and #text > 0 then
  1166.             system.playerMessage = stringsub(text,1,40)
  1167.         end
  1168.     end},
  1169.     ["!"] = {0,function(langue)
  1170.         if langue and #langue > 0 then
  1171.             system.roomLanguage = stringlower(langue)
  1172.         end
  1173.     end}
  1174. }
  1175. system.setRoom = function()
  1176.     if system.isRoom and system.roomAttributes then
  1177.         local chars = ""
  1178.         for k in next,system.roomSettings do
  1179.             chars = chars .. k
  1180.         end
  1181.  
  1182.         for char,value in stringgmatch(system.roomAttributes,"(["..chars.."])([^"..chars.."]+)") do
  1183.             for k,v in next,system.roomSettings do
  1184.                 if k == char then
  1185.                     v[2](v[1] == 0 and stringmatch(value,"[^%s]+") or value)
  1186.                     break
  1187.                 end
  1188.             end
  1189.         end
  1190.        
  1191.         local officialModes = {
  1192.             {"vanilla","<VP>Enjoy your vanilla (: .. okno"},
  1193.             {"survivor","<R>Aw, you cannot play survivor on #grounds"},
  1194.             {"racing","<CH>Uh, racing? Good luck!"},
  1195.             {"music","<BV>Music? Nice choice! Why don't you try a rock'n'roll?"},
  1196.             {"bootcamp","<PT>Bootcamp? Ok. This is unfair and your data won't be saved out of the room."},
  1197.             {"defilante","<R>Aw, you cannot play defilante on #grounds"},
  1198.             {"village","<R>You cannot play village on #grounds. Please, change your room."},
  1199.         }
  1200.         for k,v in next,officialModes do
  1201.             if stringfind(stringlower(system.roomAttributes),v[1]) then
  1202.                 system.officialMode = {v[1],v[2]}
  1203.                 break
  1204.             end
  1205.         end
  1206.     end
  1207. end
  1208.  
  1209. --[[ Initialize ]]--
  1210. execute = {}
  1211. system.setRoom()
  1212.  
  1213. system.init = function(refresh)
  1214.     for i,event in next,{"Loop","NewGame","PlayerDied","PlayerGetCheese","PlayerVampire","PlayerWon","PlayerLeft","EmotePlayed","Keyboard","Mouse","PopupAnswer","TextAreaCallback","ChatCommand","ChatMessage","SummoningStart","SummoningEnd","SummoningCancel","NewPlayer","PlayerRespawn","ColorPicked"} do
  1215.         local e = "event" .. event
  1216.        
  1217.         local found = false
  1218.         for k,v in next,mode[system.gameMode] do
  1219.             if k == e then
  1220.                 execute[e] = v
  1221.                 found = true
  1222.                 break
  1223.             end
  1224.         end
  1225.         if not found then
  1226.             execute[e] = function() end
  1227.         end
  1228.  
  1229.         _G[e] = function(...)
  1230.             if events[e] then
  1231.                 events[e](...)
  1232.             end
  1233.             execute[e](...)
  1234.         end
  1235.     end
  1236.  
  1237.     if refresh then
  1238.         if mode[system.gameMode].reset then
  1239.             mode[system.gameMode].reset()
  1240.         end
  1241.     end
  1242.    
  1243.     normalizeTranslation()
  1244.     mode[system.gameMode].init()
  1245.  
  1246.     if _G["eventNewPlayer"] then
  1247.         tableforeach(tfm.get.room.playerList,eventNewPlayer)
  1248.     end
  1249. end
  1250. system.init()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement