Bolodefchoco_LUAXML

[Game] Signal

Sep 16th, 2017
228
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 33.48 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 = "signal",
  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. --[[ Signal ]]--
  612. mode.signal = {
  613.     -- Translations
  614.     translations = {
  615.         en = {
  616.             -- Init
  617.             welcome = "Welcome to <PS>#Signal<S>! Follow the signs and join the hole! Use !help to read more informations.\n\tReport any issue to Bolodefchoco",
  618.            
  619.             -- Info
  620.             info = {
  621.                 [1] = {"Run","Run the faster you can. Do not stop!"},
  622.                 [2] = {"Attention","Pay attention! You can die in a few seconds!"},
  623.                 [3] = {"Stop","Stop or die!"},
  624.             },
  625.             skip = "<PS>[•] <S>Impossible map? Type !skip",
  626.             skipped = "Your vote to skip the map has been recorded.",
  627.            
  628.             -- Simple words
  629.             close = "Close",
  630.         },
  631.         br = {
  632.             welcome = "Bem-vindo ao <PS>#Signal<S>! Siga os sinais e entre na toca!  Use !help para ler mais informações.\n\tReporte qualquer problema para Bolodefchoco",
  633.  
  634.             info = {
  635.                 [1] = {"Corra","Corra o mais rápido que puder. Não pare!"},
  636.                 [2] = {"Atenção","Preste atenção! Você poderá morrer a qualquer momento!"},
  637.                 [3] = {"Pare","Pare ou morra!"},
  638.             },
  639.             skip = "<PS>[•] <S>Mapa impossível? Digite !skip",
  640.             skipped = "Seu voto para passar o mapa foi registrado.",
  641.  
  642.             close = "Fechar",
  643.         },
  644.         pl = {
  645.             welcome = "Witaj w <PS>#Signal<S>! Patrz na tabliczke i wejdź do norki! Użyj komendy !help, aby przeczytać wiÄ™cej informacji.\n\tZgÅ‚oÅ› wszystkie bÅ‚Ä™dy jakie znajdziesz do Bolodefchoco",
  646.            
  647.             info = {
  648.                 [1] = {"Biegnij","Biegnij jak najszybciej do norki. Nie zatrzymuj siÄ™!"},
  649.                 [2] = {"Uważaj","Uważaj! Możesz zginąć za kilka sekund!"},
  650.                 [3] = {"Stój","Stój albo zgiÅ„!"},
  651.             },
  652.             skip = "<PS>[•] <S>Niemożliwa mapa? Wpisz komendÄ™ !skip",
  653.             skipped = "Twój gÅ‚os na ominiÄ™cie mapy zostaÅ‚ policzony.",
  654.            
  655.             close = "Zamknij",
  656.         },
  657.     },
  658.     langue = "",
  659.     --[[ Data ]]--
  660.     info = {},
  661.     --[[ Maps ]]--
  662.     generateMap = function()
  663.         local groundProperties = {[0] = {.3,.2},[4] = {20,.2},[5] = {.3,.2},[6] = {.3,.2},[7] = {.1,.2},[10] = {.3,0},[11] = {.05,.1},[3] = {5,20}}
  664.         local groundDecorations = {[0] = {0,4,5},[4] = {1,42,51},[5] = {1,2,4,12,18,20,32,42,46},[6] = {0,1,2,3,4,5,11,42},[7] = {7,8,9,10},[10] = {42,103,118},[11] = {51,106},[3] = {}}
  665.         local newGround = "<S L=\"%s\" H=\"%s\" X=\"%s\" Y=\"%s\" T=\"%s\" P=\"0,0,%s,%s,0,0,0,0\" />"
  666.         local newDecoration = "<P P=\"%s,0\" X=\"%d\" Y=\"%d\" T=\"%d\" />"
  667.         local object = "<%s X=\"%s\" Y=\"%s\"/>"
  668.         local objects = {hole="T",mice="DS",cheese="F"}
  669.  
  670.         local mapHeight = mathrandom(1500,3000)
  671.  
  672.         local grounds = {}
  673.         local decorations = {}
  674.         for i = 1,mathceil(mapHeight/180) do
  675.             local T = tablerandom({0,4,5,6,7,10,11,tablerandom({4,5,6,10,3})})
  676.  
  677.             local H = T==3 and mathrandom(10,20) or mathrandom(40,100)
  678.  
  679.             local Y = (#grounds > 1 and grounds[#grounds].Y < 320 and mathrandom(230,310) or mathrandom(300,350)) or mathrandom(290,350)
  680.  
  681.             local X,L
  682.             repeat
  683.                 X = (#grounds > 1 and (grounds[#grounds].X + ((mathrandom(-1,1) * 30) + 200)) or mathrandom(50,300))
  684.                 X = X < 60 and 100 or X > mapHeight - 100 and mapHeight - 300 or X
  685.                 L = T==3 and H or mathrandom(40,mathceil(mapHeight/18))
  686.             until (X - (L/2)) > 50 and (X + (L/2)) < mapHeight - 50
  687.  
  688.             local properties = groundProperties[T]
  689.             grounds[#grounds + 1] = {X=X,Y=Y,L=L,H=H,stringformat(newGround,L,H,X,Y,T,properties[1],properties[2])}
  690.  
  691.             if T ~= 3 and mathrandom(20) < 10 then
  692.                 local decoList = groundDecorations[T]
  693.                 decorations[#decorations + 1] = stringformat(newDecoration,tablerandom({0,0,0,mathrandom(0,1),1}),X - mathrandom(-((L/4)+1),((L/4)+1)),Y - (H/2),tablerandom(decoList))
  694.             end
  695.         end
  696.        
  697.         local cheeseX
  698.         local foo = function()
  699.             for k,v in next,grounds do
  700.                 if (cheeseX + 10) > (v.X - v.L/2) and (cheeseX - 10) < (v.X + v.L/2) then
  701.                     return false
  702.                 end
  703.             end
  704.             return true
  705.         end
  706.         repeat
  707.             cheeseX = mathrandom(200,mapHeight - 500)
  708.         until foo()
  709.  
  710.         grounds[#grounds + 1] = {X=0,Y=0,L=0,H=0,stringformat(newGround,200,40,100,380,2,.3,.9)}
  711.         grounds[#grounds + 1] = {X=0,Y=0,L=0,H=0,stringformat(newGround,300,40,mapHeight - 150,380,6,.3,.2)}
  712.  
  713.         tfm.exec.newGame(stringformat("<C><P G=\"0,%s\" F=\"%s\" L=\"%s\" /><Z><S>%s</S><D>%s%s%s%s</D><O /></Z></C>",tablerandom({mathrandom(7,12),10,11,9}),tablerandom({0,1,2,3,4,5,7,8}),mapHeight,tableconcat(grounds,"",function(k,v) return v[1] end),stringformat(object,objects.hole,mapHeight - 30,360),stringformat(object,objects.mice,10,365),stringformat(object,objects.cheese,cheeseX,mathrandom(280,340)),tableconcat(decorations)))
  714.     end,
  715.     loadMap = function()
  716.         mode.signal.rounds = mode.signal.rounds + 1
  717.        
  718.         if mode.signal.rounds % 5 == 0 or system.miscAttrib > 0 then
  719.             mode.signal.generateMap()
  720.         else
  721.             tfm.exec.newGame("#7")
  722.         end
  723.     end,
  724.     --[[ Settings ]]--
  725.     -- New Game
  726.     sys = {0,1},
  727.     discrepancy = 0,
  728.     lights = {"15b52f8717d","15b52f8583a","15b52f88765"},
  729.     lightId = -1,
  730.     skip = 0,
  731.     rounds = 0,
  732.     possible = false,
  733.     isGeneratedMap = false,
  734.     -- UpdateLight
  735.     update = function(id)
  736.         tfm.exec.removeImage(mode.signal.lightId)
  737.         mode.signal.lightId = tfm.exec.addImage(mode.signal.lights[mode.signal.sys[2]] .. ".png","&0",375,30)
  738.         local color = ({0x1CB70C,0xF4D400,0xEC0000})[mode.signal.sys[2]]
  739.         for k,v in next,mode.signal.info do
  740.             if id == 1 then
  741.                 if not v.afk and v.canRev then
  742.                     tfm.exec.respawnPlayer(k)
  743.                 end
  744.             end
  745.             tfm.exec.setNameColor(k,color)
  746.         end
  747.     end,
  748.     --[[ UI ]]--
  749.     displayInfo = function(n,id)
  750.         local color = ({"<VP>","<J>","<R>"})[id]
  751.         ui.addTextArea(1,"<p align='center'><font size='25'>" .. color .. system.getTranslation("info."..id..".1") .. "\n</font></p><p align='left'><font size='14'>" .. system.getTranslation("info."..id..".2"),n,250,110,300,181,0x324650,0x27343A,1,true)
  752.         ui.addTextArea(2,"<font size='2'>\n</font><p align='center'><font size='16'><a href='event:close'>" .. system.getTranslation("close"),n,250,300,300,30,0x27343A,0x27343A,1,true)
  753.         ui.addTextArea(3,"<p align='center'><font size='20'><a href='event:info.1'><VP>•</a> <a href='event:info.2'><J>•</a> <a href='event:info.3'><R>•</a>",n,250,145,300,30,1,1,0,true)
  754.         tfm.exec.removeImage(mode.signal.info[n].imageId)
  755.         mode.signal.info[n].imageId = tfm.exec.addImage(mode.signal.lights[id] .. ".png","&1",375,200,n)
  756.     end,
  757.     --[[ Init ]]--
  758.     reset = function()
  759.         -- Data
  760.         mode.signal.info = {}
  761.     end,
  762.     init = function()
  763.         for _,f in next,{"AutoShaman","AutoNewGame","AutoTimeLeft","PhysicalConsumables"} do
  764.             tfm.exec["disable"..f]()
  765.         end
  766.  
  767.         mode.signal.loadMap()
  768.     end,
  769.     --[[ Events ]]--
  770.     -- NewPlayer
  771.     eventNewPlayer = function(n)
  772.         if not mode.signal.info[n] then
  773.             mode.signal.info[n] = {
  774.                 isMoving = {false,false,false,false},
  775.                 imageId = -1,
  776.                 afk = true,
  777.                 skipped = false,
  778.                 canRev = true,
  779.             }
  780.         end
  781.         for i = 0,3 do
  782.             system.bindKeyboard(n,i,true,true)
  783.             system.bindKeyboard(n,i,false,true)
  784.         end
  785.         tfm.exec.chatMessage("<S>" .. system.getTranslation("welcome"),n)
  786.        
  787.         ui.banner("15d60d9212c",220,130,n)
  788.     end,
  789.     -- NewGame
  790.     eventNewGame = function()
  791.         mode.signal.skip = 0
  792.         mode.signal.possible = false
  793.        
  794.         mode.signal.isGeneratedMap = tfm.get.room.xmlMapInfo.author == "#Module"
  795.        
  796.         if mode.signal.isGeneratedMap and mode.signal.rounds % 3 == 0 then
  797.             tfm.exec.chatMessage(system.getTranslation("skip"))
  798.         end
  799.        
  800.         ui.setMapName((mode.signal.isGeneratedMap and "<BL>@" .. mathrandom(999) or tfm.get.room.xmlMapInfo.author .. " <BL>- " .. tfm.get.room.currentMap) .. "   <G>|   <N>Round : <V>" .. mode.signal.rounds)
  801.        
  802.         for k,v in next,mode.signal.info do
  803.             v.isMoving = {false,false,false,false}
  804.             v.afk = true
  805.             v.skipped = false
  806.             v.canRev = true
  807.         end
  808.        
  809.         mode.signal.sys = {0,1}
  810.         mode.signal.update(mode.signal.sys[2])
  811.     end,
  812.     -- Keyboard
  813.     eventKeyboard = function(n,k,d)
  814.         if mode.signal.sys[2] == 3 and d and os.time() > mode.signal.discrepancy then
  815.             tfm.exec.killPlayer(n)
  816.         else
  817.             mode.signal.info[n].isMoving[k + 1] = d
  818.         end
  819.         mode.signal.info[n].afk = false
  820.     end,
  821.     -- Loop
  822.     eventLoop = function(currentTime,leftTime)
  823.         if _G.currentTime > 8 then
  824.             if os.time() > mode.signal.sys[1] then
  825.                 mode.signal.sys[2] = (mode.signal.sys[2] % 3) + 1
  826.                 mode.signal.sys[1] = os.time() + ({mathrandom(7,13),mathrandom(2,3),mathrandom(3,5)})[mode.signal.sys[2]] * 1000
  827.                 mode.signal.update(mode.signal.sys[2])
  828.                 mode.signal.discrepancy = os.time() + 520
  829.             end
  830.         end
  831.  
  832.         if _G.leftTime > 2 and system.players() > 0 then
  833.             if mode.signal.sys[2] == 3 and os.time() > mode.signal.discrepancy then
  834.                 for k,v in next,mode.signal.info do
  835.                     for i,j in next,v.isMoving do
  836.                         if j then
  837.                             tfm.exec.killPlayer(k)
  838.                             break
  839.                         end
  840.                     end
  841.                 end
  842.             end
  843.         else
  844.             mode.signal.loadMap()
  845.         end
  846.     end,
  847.     -- TextAreaCallback
  848.     eventTextAreaCallback = function(i,n,c)
  849.         local p = stringsplit(c,"[^%.]+")
  850.         if p[1] == "info" then
  851.             mode.signal.displayInfo(n,tonumber(p[2]))
  852.         elseif p[1] == "close" then
  853.             tfm.exec.removeImage(mode.signal.info[n].imageId)
  854.             for i = 1,3 do
  855.                 ui.removeTextArea(i,n)
  856.             end
  857.         end
  858.     end,
  859.     -- ChatCommand
  860.     eventChatCommand = function(n,c)
  861.         if c == "info" or c == "help" or c == "?" then
  862.             eventTextAreaCallback(nil,n,"info." .. mode.signal.sys[2])
  863.         elseif c == "skip" and _G.currentTime > 8 and not mode.signal.possible and not mode.signal.info[n].skipped and mode.signal.isGeneratedMap then
  864.             mode.signal.skip = mode.signal.skip + 1
  865.             tfm.exec.chatMessage(system.getTranslation("skipped"),n)
  866.            
  867.             local alive,total = system.players()
  868.             if mode.signal.skip == mathceil(.5 * total) then
  869.                 tfm.exec.chatMessage("o/")
  870.                 mode.signal.loadMap()
  871.             end
  872.         end
  873.     end,
  874.     -- PlayerWon
  875.     eventPlayerWon = function(n)
  876.         mode.signal.possible = true
  877.         mode.signal.info[n].canRev = false
  878.         tfm.exec.setGameTime(40,false)
  879.     end,
  880. }
  881.  
  882. --[[ ModeChanged ]]--
  883. system.objects = {
  884.     image = {},
  885.     textarea = {}
  886. }
  887. eventModeChanged = function()
  888.     -- Remove content
  889.     for k in next,system.objects.image do
  890.         tfm.exec.removeImage(k)
  891.     end
  892.    
  893.     for k in next,system.objects.textarea do
  894.         ui.removeTextArea(k,nil)
  895.     end
  896.    
  897.     system.objects = {
  898.         image = {},
  899.         textarea = {}
  900.     }
  901.    
  902.     ui.addPopup(0,0,"",nil,-1500,-1500)
  903.    
  904.     -- Unbind keyboard and mouse, also normalize color name and scores
  905.     for k in next,tfm.get.room.playerList do
  906.         for i = 0,255 do
  907.             for v = 0,1 do
  908.                 system.bindKeyboard(k,i,v == 0,false)
  909.             end
  910.         end
  911.        
  912.         system.bindMouse(k,false)
  913.        
  914.         tfm.exec.setNameColor(k,-1)
  915.         tfm.exec.setPlayerScore(k,0)
  916.     end
  917.    
  918.     -- Set admin back
  919.     system.roomAdmins = system.setAdmins()
  920.    
  921.     -- Reset settings
  922.     tfm.exec.snow(0)
  923.     for k,v in next,{"AutoScore","WatchCommand","AutoNewGame","AutoShaman","AllShamanSkills","MortCommand","DebugCommand","MinimalistMode","AfkDeath","PhysicalConsumables","AutoTimeLeft"} do
  924.         tfm.exec["disable" .. v](false)
  925.     end
  926.     tfm.exec.setAutoMapFlipMode()
  927.    
  928.     tfm.exec.setRoomMaxPlayers(25)
  929.     tfm.exec.setRoomPassword("")   
  930. end
  931.  
  932. --[[ Events ]]--
  933.     --[[ eventLoop ]]--
  934. events.eventLoop = function(currentTime,leftTime)
  935.     _G.currentTime = normalizeTime(currentTime / 1e3)
  936.     _G.leftTime = normalizeTime(leftTime / 1e3)
  937. end
  938.     --[[ eventNewPlayer ]]--
  939. events.eventNewPlayer = function(n)
  940.     tfm.exec.lowerSyncDelay(n)
  941.    
  942.     if system.officialMode[2] ~= "" then
  943.         tfm.exec.chatMessage(system.officialMode[2],n)
  944.     end
  945.    
  946.     if system.playerMessage ~= "" then
  947.         tfm.exec.chatMessage("<J>" .. system.playerMessage,n)
  948.     end
  949. end
  950.     --[[ eventChatCommand ]]--
  951. events.eventChatCommand = function(n,c)
  952.     if system.isPlayer(n) then
  953.         system.disableChatCommandDisplay(c,true)
  954.        
  955.         local p = stringsplit(c,"[^%s]+",stringlower)
  956.         disableChatCommand(p[1])
  957.    
  958.         if module._FREEACCESS[n] then
  959.             if p[1] == "refresh" and (module._FREEACCESS[n] > 1 or not system.isRoom) then
  960.                 eventModeChanged()
  961.                 system.init(true)
  962.                 return
  963.             end
  964.            
  965.             if p[1] == "room" and (module._FREEACCESS[n] > 1 or not system.isRoom) then
  966.                 local room = tonumber(p[2]) or 0
  967.                 if _G["eventChatCommand"] and system.roomNumber ~= room then
  968.                     system.roomNumber = room
  969.                     eventChatCommand(n,"refresh")
  970.                 end
  971.                 return
  972.             end
  973.            
  974.             if p[1] == "setmisc" and p[2] and (module._FREEACCESS[n] > 1 or not system.isRoom) then
  975.                 system.miscAttrib = tonumber(p[2]) or 0
  976.                 system.miscAttrib = mathsetLim(system.miscAttrib,0,99)
  977.                 if p[3] == "true" then
  978.                     eventChatCommand(n,"refresh")
  979.                 end
  980.                 return
  981.             end
  982.            
  983.             if p[1] == "load" and (module._FREEACCESS[n] > 2 or not system.isRoom) then
  984.                 if os.time() > system.modeChanged and os.time() > system.newGameTimer then
  985.                     if system.getGameMode(p[2],true) then
  986.                         system.init(system.isRoom)
  987.                     end
  988.                 end            
  989.                 return
  990.             end
  991.         end
  992.        
  993.         if p[1] == "module" then
  994.             p[2] = stringupper(p[2] or "")
  995.            
  996.             if module["_" .. p[2]] then
  997.                 if p[2] == "FREEACCESS" then
  998.                     if p[3] then
  999.                         p[3] = stringnick(p[3])
  1000.                         tfm.exec.chatMessage(p[3] .. " ~> " .. (module._FREEACCESS[p[3]] or 0),n)
  1001.                     else
  1002.                         tfm.exec.chatMessage(p[2] .. " : ",n)
  1003.                         for k,v in pairsByIndexes(module._FREEACCESS,function(a,b) return module._FREEACCESS[a] > module._FREEACCESS[b] end) do
  1004.                             tfm.exec.chatMessage(stringformat("%s ~> %s",k,v),n)
  1005.                         end
  1006.                     end
  1007.                 else
  1008.                     tfm.exec.chatMessage(p[2] .. " : " .. tableconcat(tableturnTable(module["_" .. p[2]]),"\n",function(k,v)
  1009.                         return v
  1010.                     end),n)
  1011.                 end
  1012.             else
  1013.                 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)
  1014.             end
  1015.             return
  1016.         end
  1017.        
  1018.         if p[1] == "modes" then
  1019.             tfm.exec.chatMessage(tableconcat({tableunpack(system.submodes,2)},"\n",function(k,v)
  1020.                 return stringformat("~> /room #%s%s@%s#%s",module._NAME,mathrandom(0,999),n,v)
  1021.             end),n)
  1022.             return
  1023.         end
  1024.  
  1025.         if p[1] == "stop" and system.roomAdmins[n] then
  1026.             system.exit()
  1027.         end
  1028.        
  1029.         if p[1] == "admin" then
  1030.             tfm.exec.chatMessage(tableconcat(system.roomAdmins,", ",tostring),n)
  1031.             return
  1032.         end
  1033.        
  1034.         if p[1] == "adm" and p[2] and (system.roomAdmins[n] or (module._FREEACCESS[n] and module._FREEACCESS[n] > 2)) then
  1035.             if tablefind({"true","false"},p[3]) then
  1036.                 local pl = stringnick(p[2])
  1037.                 system.roomAdmins[pl] = (module._FREEACCESS[pl] and true) or p[3] == "true" or nil
  1038.             end
  1039.             return
  1040.         end
  1041.        
  1042.         if p[1] == "setroomlanguage" and p[2] and (system.roomAdmins[n] or (module._FREEACCESS[n] and module._FREEACCESS[n] > 2)) then
  1043.             if mode[system.gameMode].translations[p[2]] then
  1044.                 system.roomLanguage = p[2]
  1045.                 mode[system.gameMode].langue = system.roomLanguage
  1046.             end
  1047.             return
  1048.         end
  1049.        
  1050.         if p[1] == "me" then
  1051.             local commands = {
  1052.                 [0] = {},
  1053.                 [1] = {"!refresh (tribe house)","!setMisc [number] [refresh] (tribe house)","!room [number] (tribe house)","!load [mode] (tribe house)"},
  1054.                 [2] = {"!refresh","!setMisc [number] [refresh]","!room [number]","!load [mode] (tribe house)"},
  1055.                 [3] = {"!refresh","!setMisc [number] [refresh]","!room [number]","!load [mode]"}
  1056.             }
  1057.            
  1058.             local access = module._FREEACCESS[n] or 0
  1059.            
  1060.             if system.roomAdmins[n] then
  1061.                 for k,v in next,{"!stop","!adm [playerName] [true/false]","!setRoomLanguage [language]"} do
  1062.                     commands[access][#commands[access] + 1] = v
  1063.                 end
  1064.             end
  1065.            
  1066.             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)
  1067.             return
  1068.         end
  1069.     end
  1070. end
  1071.  
  1072. --[[ RoomSettings ]]--
  1073. system.roomSettings = {
  1074.     -- 0 = Only the first value
  1075.     -- 1 = All the text
  1076.     ["@"] = {0,function(n)
  1077.         if n and #n > 2 then
  1078.             system.roomAdmins[stringnick(n)] = true
  1079.         end
  1080.     end},
  1081.     ["*"] = {0,function(id)
  1082.         system.miscAttrib = tonumber(id) or 1
  1083.         system.miscAttrib = mathsetLim(system.miscAttrib,1,99)
  1084.     end},
  1085.     ["#"] = {0,function(name)
  1086.         if name then
  1087.             local game = system.getGameMode(name)
  1088.             if not game then
  1089.                 system.gameMode = module._NAME
  1090.             end
  1091.         end
  1092.     end},
  1093.     [":"] = {1,function(text)
  1094.         if text and #text > 0 then
  1095.             system.playerMessage = stringsub(text,1,40)
  1096.         end
  1097.     end},
  1098.     ["!"] = {0,function(langue)
  1099.         if langue and #langue > 0 then
  1100.             system.roomLanguage = stringlower(langue)
  1101.         end
  1102.     end}
  1103. }
  1104. system.setRoom = function()
  1105.     if system.isRoom and system.roomAttributes then
  1106.         local chars = ""
  1107.         for k in next,system.roomSettings do
  1108.             chars = chars .. k
  1109.         end
  1110.  
  1111.         for char,value in stringgmatch(system.roomAttributes,"(["..chars.."])([^"..chars.."]+)") do
  1112.             for k,v in next,system.roomSettings do
  1113.                 if k == char then
  1114.                     v[2](v[1] == 0 and stringmatch(value,"[^%s]+") or value)
  1115.                     break
  1116.                 end
  1117.             end
  1118.         end
  1119.        
  1120.         local officialModes = {
  1121.             {"vanilla","<VP>Enjoy your vanilla (: .. okno"},
  1122.             {"survivor","<R>Aw, you cannot play survivor on #grounds"},
  1123.             {"racing","<CH>Uh, racing? Good luck!"},
  1124.             {"music","<BV>Music? Nice choice! Why don't you try a rock'n'roll?"},
  1125.             {"bootcamp","<PT>Bootcamp? Ok. This is unfair and your data won't be saved out of the room."},
  1126.             {"defilante","<R>Aw, you cannot play defilante on #grounds"},
  1127.             {"village","<R>You cannot play village on #grounds. Please, change your room."},
  1128.         }
  1129.         for k,v in next,officialModes do
  1130.             if stringfind(stringlower(system.roomAttributes),v[1]) then
  1131.                 system.officialMode = {v[1],v[2]}
  1132.                 break
  1133.             end
  1134.         end
  1135.     end
  1136. end
  1137.  
  1138. --[[ Initialize ]]--
  1139. execute = {}
  1140. system.setRoom()
  1141.  
  1142. system.init = function(refresh)
  1143.     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
  1144.         local e = "event" .. event
  1145.        
  1146.         local found = false
  1147.         for k,v in next,mode[system.gameMode] do
  1148.             if k == e then
  1149.                 execute[e] = v
  1150.                 found = true
  1151.                 break
  1152.             end
  1153.         end
  1154.         if not found then
  1155.             execute[e] = function() end
  1156.         end
  1157.  
  1158.         _G[e] = function(...)
  1159.             if events[e] then
  1160.                 events[e](...)
  1161.             end
  1162.             execute[e](...)
  1163.         end
  1164.     end
  1165.  
  1166.     if refresh then
  1167.         if mode[system.gameMode].reset then
  1168.             mode[system.gameMode].reset()
  1169.         end
  1170.     end
  1171.    
  1172.     normalizeTranslation()
  1173.     mode[system.gameMode].init()
  1174.  
  1175.     if _G["eventNewPlayer"] then
  1176.         tableforeach(tfm.get.room.playerList,eventNewPlayer)
  1177.     end
  1178. end
  1179. system.init()
Add Comment
Please, Sign In to add comment