Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --Creator: Bolodefchoco
- --Made in: 06/02/2017
- --Last update: 16/09/2017
- --[[ Module ]]--
- local module = {
- _VERSION = "1",
- _NAME = "hardcamp",
- _STATUS = "semi-official",
- _AUTHOR = "Bolodefchoco",
- _LICENSE = [[
- MIT LICENSE
- Copyright (c) 2017 @Transformice + @Bolodefchoco
- Permission is hereby granted, free of charge, to any person obtaining
- a copy of this software and associated documentation files (the
- "Software"), to deal in the Software without restriction, including
- without limitation the rights to use, copy, modify, merge, and to
- permit persons to whom the Software is furnished to do so, subject to
- the following conditions:
- The above copyright notice and this permission notice shall be included
- in all copies or substantial portions of the Software.
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF FITNESS FOR
- A PARTICULAR PURPOSE AND NONINFRINGEMENT.
- IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
- CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
- TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
- SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- ]],
- _FREEACCESS = { -- Verified players
- -- 3 : Commands + Room admin + Debug
- Bolodefchoco = 3,
- Trumpuke = 3,
- -- 2 : Commands
- Bodykudo = 2,
- Error_404 = 2,
- Jordynl = 2,
- Laagaadoo = 2,
- Mescouleur = 2,
- Sebafrancuz = 2,
- Tocutoeltuco = 2,
- -- 1 : Some commands
- Abdeltif = 1,
- Animjarcanin = 1,
- Artinoe = 1,
- Atinesta = 1,
- Auroraclears = 1,
- Bapereira = 1,
- Barberserk = 1,
- Bataatiinha = 1,
- Bellaxo = 1,
- Bibsho = 1,
- Bielbateriax = 1,
- Bjikata = 1,
- Bruniinhoowx = 1,
- Byontr = 1,
- Caiolopelope = 1,
- Chocodivo = 1,
- Claumiau = 1,
- Connow = 1,
- Daelea = 1,
- Distances = 1,
- Drescen = 1,
- Ekull = 1,
- Exsilium = 1,
- Flindix = 1,
- Gemalugeter = 1,
- Grastfetry = 1,
- Grincreep = 1,
- Ikkemon = 1,
- Jotatavo = 1,
- Kimsterjay = 1,
- Kingtenso = 1,
- Lebluemice = 1,
- Lucasrslv = 1,
- Mcqv = 1,
- Miyakogotoku = 1,
- Mousetat = 1,
- Mquk = 1,
- Myelou = 1,
- Nedior = 1,
- Nlff = 1,
- Okpatinhos = 1,
- Pjfsamora = 1,
- Prysmos = 1,
- Reshman = 1,
- Rianmojang1 = 1,
- Rosianna_rabbit = 1,
- Ruamorangos = 1,
- Sammynya = 1,
- Squalleze = 1,
- Tdft = 1,
- Thegbc = 1,
- Tockego = 1,
- Treasuredsoul = 1,
- Victorruanpk = 1,
- Viniciusdara = 1,
- Vinitexeira = 1,
- Xfelrat = 1,
- Xorcist = 1,
- Yuir = 1,
- Zacriker = 1,
- Zippydoodah = 1,
- Zagear = 1,
- Zombiewd = 1,
- },
- }
- --[[ Optimization ]]--
- --[[ String ]]--
- 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
- --[[ Math ]]--
- 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
- --[[ Table ]]--
- 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
- --[[ API ]]--
- --[[ Control ]]--
- system.newGameTimer = 0
- system.officialMode = {"",""}
- system.playerMessage = ""
- system.setAdmins = function()
- local out = {}
- for k,v in next,module._FREEACCESS do
- if v > 2 then
- out[k] = true
- end
- end
- return out
- end
- --[[ Improvements ]]--
- tableconcat = function(list,sep,f,i,j)
- local txt = ""
- sep = sep or ""
- i,j = i or 1,j or #list
- for k,v in next,list do
- if type(k) ~= "number" and true or (k >= i and k <= j) then
- txt = txt .. (f and f(k,v) or v) .. sep
- end
- end
- return stringsub(txt,1,-1-#sep)
- end
- do
- local newGame = tfm.exec.newGame
- tfm.exec.newGame = function(code)
- if os.time() > system.newGameTimer then
- system.newGameTimer = os.time() + 6000
- 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}))
- return true
- end
- return false
- end
- local addImage = tfm.exec.addImage
- local removeImage = tfm.exec.removeImage
- tfm.exec.addImage = function(...)
- local id = addImage(...)
- if id then
- system.objects.image[id] = true
- end
- return id or -1
- end
- tfm.exec.removeImage = function(id)
- removeImage(id)
- if system.objects.image[id] then
- system.objects.image[id] = nil
- end
- end
- local addTextArea = ui.addTextArea
- ui.addTextArea = function(id,...)
- addTextArea(id,...)
- if not system.objects.textarea[id] then
- system.objects.textarea[id] = true
- end
- end
- local chatMessage = tfm.exec.chatMessage
- tfm.exec.chatMessage = function(txt,n)
- txt = tostring(txt)
- if #txt > 1000 then
- local total = 0
- while #txt > total do
- chatMessage(stringsub(txt,total,total + 1000),n)
- total = total + 1001
- end
- else
- chatMessage(txt,n)
- end
- end
- local loadPlayerData = system.loadPlayerData
- system.loadPlayerData = function(n)
- if module._STATUS == "official" then
- return loadPlayerData(n)
- else
- if _G["eventPlayerDataLoaded"] then
- eventPlayerDataLoaded(n,"")
- end
- return true
- end
- end
- local savePlayerData = system.savePlayerData
- system.savePlayerData = function(n,data)
- if module._STATUS == "official" then
- savePlayerData(n,data)
- return true
- else
- return false
- end
- end
- end
- --[[ Room ]]--
- system.isRoom = stringbyte(tfm.get.room.name,2) ~= 3
- system.roomAdmins = system.setAdmins()
- system.miscAttrib = 0
- system.roomNumber,system.roomAttributes = (function()
- if system.isRoom then
- local number,attribute = stringmatch(tfm.get.room.name,"%*?#"..module._NAME.."(%d+)(.*)")
- return tonumber(number) or 0,attribute or ""
- else
- return 0,""
- end
- end)()
- system.roomLanguage = ""
- --[[ Player ]]--
- system.isPlayer = function(n)
- --[[
- The player must not be a souris;
- The player must have played Transformice for at least 5 days
- ]]
- 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
- end
- system.players = function(alivePlayers)
- local alive,total = 0,0
- if alivePlayers then
- alive = {}
- end
- for k,v in next,tfm.get.room.playerList do
- if system.isPlayer(k) then
- if not v.isDead and not v.isVampire then
- if alivePlayers then
- alive[#alive + 1] = k
- else
- alive = alive + 1
- end
- end
- total = total + 1
- end
- end
- if alivePlayers then
- return alive
- else
- return alive,total
- end
- end
- --[[ System ]]--
- events = {}
- currentTime,leftTime = 0,0
- system.loadTable = function(s)
- -- "a.b.c.1" returns a[b][c][1]
- local list
- for tbl in stringgmatch(s,"[^%.]+") do
- tbl = tonumber(tbl) and tonumber(tbl) or tbl
- list = (list and list[tbl] or _G[tbl])
- end
- return list
- end
- system.getTranslation = function(index,n)
- local t = stringformat("mode.%s.translations.%s.%s",system.gameMode,(n and mode[system.gameMode].info[n].langue or mode[system.gameMode].langue),index)
- return system.loadTable(t) or system.loadTable(stringgsub(t,"translations%..-%.",function() return "translations.en." end))
- end
- system.looping = function(f,tick)
- local s = 1000 / tick
- local t = {}
- local fooTimer = function()
- t[#t+1] = system.newTimer(f,1000,true)
- end
- for timer = 0,1000 - s,s do
- system.newTimer(fooTimer,1000 + timer,false)
- end
- return t
- end
- --[[ Interface ]]--
- ui.banner = function(image,aX,aY,n,time)
- time = time or 5
- axis = axis or {100,100}
- local img = tfm.exec.addImage(image .. ".png","&0",aX,aY,n)
- system.newTimer(function()
- tfm.exec.removeImage(img)
- end,time * 1000,false)
- end
- --[[ Math ]]--
- mathisNegative = function(x,iN,iP)
- iN = iN == nil and x or iN
- iP = iP == nil and x or iP
- return (x<0 and iN or iP)
- end
- mathpercent = function(x,y,v)
- v = (v or 100)
- local m = x/y * v
- return mathmin(m,v)
- end
- mathpythag = function(x1,y1,x2,y2,range)
- return (x1-x2)^2 + (y1-y2)^2 <= (range^2)
- end
- mathsetLim = function(value,min,max)
- return mathmax(min,mathmin(max,value))
- end
- --[[ String ]]--
- stringsplit = function(value,pattern,f)
- local out = {}
- for v in stringgmatch(value,pattern) do
- out[#out + 1] = (f and f(v) or v)
- end
- return out
- end
- stringnick = function(player)
- return stringgsub(stringlower(player),"%a",stringupper,1)
- end
- stringtrim = function(s)
- return (stringgsub(s,"^%s*(.-)%s*$","%1"))
- end
- --[[ Table ]]--
- tablefind = function(list,value,index,f)
- for k,v in next,list do
- local i = (type(v) == "table" and index and v[index] or v)
- if (f and f(i) or i) == value then
- return true,k
- end
- end
- return false,0
- end
- tableturnTable = function(x)
- return (type(x)=="table" and x or {x})
- end
- tablerandom = function(t)
- return (type(t) == "table" and t[mathrandom(#t)] or mathrandom())
- end
- tableshuffle = function(t)
- local randomized = {}
- for v = 1,#t do
- tableinsert(randomized,mathrandom(#randomized),t[v])
- end
- return randomized
- end
- tablemerge = function(this,src)
- for k,v in next,src do
- if this[k] then
- if type(v) == "table" then
- this[k] = tableturnTable(this[k])
- tablemerge(this[k],v)
- else
- this[k] = this[k] or v
- end
- else
- this[k] = v
- end
- end
- end
- --[[ Others ]]--
- deactivateAccents=function(str)
- local letters = {a = {"á","â","à","å","ã","ä"},e = {"é","ê","è","ë"},i = {"í","î","ì","ï"},o = {"ó","ô","ò","õ","ö"},u = {"ú","û","ù","ü"}}
- for k,v in next,letters do
- for i = 1,#v do
- str = stringgsub(str,v[i],tostring(k))
- end
- end
- return str
- end
- normalizeTime = function(time)
- return mathfloor(time) + ((time - mathfloor(time)) >= .5 and .5 or 0)
- end
- disableChatCommand = function(command,...)
- for k,v in next,{command,...} do
- system.disableChatCommandDisplay(v,true)
- system.disableChatCommandDisplay(stringlower(v),true)
- system.disableChatCommandDisplay(stringupper(v),true)
- end
- end
- normalizeTranslation = function()
- local t = mode[system.gameMode].translations
- if mode[system.gameMode].langue == "" then
- mode[system.gameMode].translations.pt = mode[system.gameMode].translations.br
- -- Sets the main language according to the community
- local p = {system.roomLanguage,tfm.get.room.community}
- for i = 1,#p do
- if mode[system.gameMode].translations[p[i]] then
- mode[system.gameMode].langue = p[i]
- end
- end
- end
- for k,v in next,t do
- if k ~= "en" then
- tablemerge(v,t.en)
- end
- end
- end
- normalizeNumber = function(number,sep)
- sep = sep or " "
- number = tostring(mathfloor(number))
- number = stringgsub(number,"E(%d+)",function(cn) -- e5 = 00000
- return stringrep("0",tonumber(cn))
- end)
- number = stringgsub(stringreverse(number),"(...)",function(c)
- return c .. sep
- end)
- return stringreverse(number)
- end
- pairsByIndexes = function(list,f)
- local out = {}
- for index in next,list do
- out[#out + 1] = index
- end
- tablesort(out,f)
- local i = 0
- return function()
- i = i + 1
- if out[i] == nil then
- return nil
- else
- return out[i],list[out[i]]
- end
- end
- end
- --[[ XML ]]--
- xml = {}
- xml.parse = function(currentXml)
- currentXml = stringmatch(currentXml,"<P (.-)/>") or ""
- local out = {}
- for tag,_,value in stringgmatch(currentXml,"([%-%w]+)=([\"'])(.-)%2") do
- out[tag] = value
- end
- return out
- end
- xml.attribFunc = function(currentXml,funcs)
- local attributes = xml.parse(currentXml)
- for k,v in next,funcs do
- if attributes[v.attribute] then
- v.func(attributes[v.attribute])
- end
- end
- end
- xml.addAttrib = function(currentXml,out,launch)
- local parameters = stringmatch(currentXml,"<P (.-)/>") or ""
- for k,v in next,out do
- if not stringfind(parameters,v.tag) then
- currentXml = stringgsub(currentXml,"<P (.-)/>",function(attribs)
- return stringformat("<P %s=\"%s\" %s/>",v.tag,v.value,attribs)
- end)
- end
- end
- if launch then
- tfm.exec.newGame(currentXml)
- else
- return currentXml
- end
- end
- xml.getCoordinates = function(s)
- if stringfind(s,";") then
- local x,y
- local axis,value = stringmatch(s,"(%a);(%d+)")
- value = tonumber(value)
- if value then
- if axis == "x" then x = value else y = value end
- end
- return x or 0,y or 0
- else
- local pos = {}
- for x,y in stringgmatch(s,"(%d+) ?, ?(%d+)") do
- pos[#pos+1] = {x = x,y = y}
- end
- return pos
- end
- end
- --[[ Color ]]--
- color = {
- hexToRgb = function(hex)
- local h = stringformat("%06x",hex)
- return tonumber("0x"..stringsub(h,1,2)),tonumber("0x"..stringsub(h,3,4)),tonumber("0x"..stringsub(h,5,6))
- end,
- rgbToHsl = function(r,g,b)
- r,g,b = r/255,g/255,b/255
- local max,min = mathmax(r,g,b),mathmin(r,g,b)
- local h,s,l
- h = (max + min) / 2
- s,l = h,h
- if max == min then
- h,s = 0,0
- else
- local d = max - min
- local s = l > .5 and (d/(2 - max - min)) or (d/(max + min))
- if max == r then
- h = (g-b)/d
- if g < b then
- h = h + 6
- end
- elseif max == g then
- h = (b-r)/d + 2
- elseif max == b then
- h = (r-g)/d + 4
- end
- h = h/6
- end
- return {h=h,s=s,l=l}
- end,
- hslToRgb = function(h,s,l)
- local r,g,b
- if s == 0 then
- r,g,b = l,l,l
- else
- local hueToRgb = function(p,q,t)
- if t < 0 then
- t = t + 1
- end
- if t > 1 then
- t = t - 1
- end
- if t < 1/6 then
- return p + (q - p) * 6 * t
- end
- if t < 1/2 then
- return q
- end
- if t < 2/3 then
- return p + (q - p) * (2/3 - t) * 6
- end
- return p
- end
- local q = l < .5 and (l * (1 + s)) or (l + s - l * s)
- local p = 2 * l - q
- r = hueToRgb(p,q,h + 1/3)
- g = hueToRgb(p,q,h)
- b = hueToRgb(p,q,h - 1/3)
- end
- return r * 255,g * 255,b * 255
- end,
- rgbToHex = function(r,g,b)
- return tonumber(stringformat('%02x%02x%02x',r,g,b),16)
- end,
- YELLOW = 0xF9EC27,
- RED = 0xF94226,
- LIGHT_RED = 0xD1605D,
- BLUE = 0x34A4E5,
- DEEP_BLUE = 0x4F7F9A,
- DARK_BLUE = 0x2D80AF,
- GRAY = 0x969696,
- SALMON = 0xAC6C64,
- BROWN = 0x89635A,
- BEIGE = 0x937A53,
- TURQUOISE = 0x59D1C8,
- ROSE = 0x816669,
- MOSS_GREEN = 0x689636,
- }
- --[[ GameMode ]]--
- system.submodes = {}
- system.gameMode = module._NAME
- system.modeChanged = os.time() + 1000
- system.getGameMode = function(value,notFirst)
- local found,submode = tablefind(system.submodes,stringlower(value),nil,stringlower)
- if found then
- system.gameMode = system.submodes[submode]
- if notFirst then
- eventModeChanged()
- end
- system.modeChanged = os.time() + 1000
- end
- return found
- end
- --[[ Modes ]]--
- mode = setmetatable({},{
- __newindex = function(list,key,value)
- rawset(list,key,setmetatable(value,{
- __index = function(nList,nKey)
- if nKey == "langue" then
- return "en"
- end
- end
- }))
- system.submodes[#system.submodes+1] = key
- end
- })
- --[[ Hardcamp ]]--
- mode.hardcamp = {
- -- Translations
- translations = {
- en = {
- -- Init
- welcome = "Welcome to <B>#Hardcamp</B>! Type !info to check the commands\n\tReport any issue to Bolodefchoco!",
- -- Info
- info = "Checkpoint:\n\tIf the checkpoint system is enabled, press <B>E</B> to put a checkpoint and <B>Shift+E</B> to remove it.\nAdmin\n\tIf you are a room admin, there are some commands that you can execute:\n\tMaps\n\t\t!next <V>--> Pass the map</V>\n\t\t!again <V>--> Resets the current map</V>\n\t\t!np @Code <VP>or</VP> !map @Code <V>--> Loads a map</V>\n\t\t!queue clear <V>--> Clear the map queue</V>\n\t\t!queue add @Code <V>--> Adds a map in the map queue</V>\n\t\t!queue P3 <VP>or</VP> P13 <VP>or</VP> P23 <V>--> Adds the whole official rotation of P3 or P13 or P23 in the map queue</V>\n\tTime\n\t\t!time TimeInMinutes <V>--> Set the time of the current round in TimeInMinutes</V>\n\t\t!standtime TimeInMinutes <V>--> Set the time of all the rounds in TimeInMinutes</V>\n\tOthers\n\t\t<B>Shift+Click</B> in a ground to read its properties\n\t\t!checkpoint [[not] cheese] <V>--> Enables/Disables the checkpoint system</V>\n\t\tKey Delete <V>--> Kills you</V>",
- skip = "<VP>%s</VP> just skipped the map!",
- restart = "<VP>%s</VP> just restarted the current map!",
- loadmap = "<VP>%s</VP> just loaded the map %s!",
- settime = "The time has been set to %s minutes!",
- setstandtime = "The standard time of all the rounds has been set to %s minutes!",
- enabled = "enabled! Press <B>E</B> to put a checkpoint and <B>Shift+E</B> to remove it.",
- queuecleared = "%s just cleared the map queue",
- queuemapadded = "%s just added the map %s to the map queue",
- queueperm = "%s just added the category %s to the map queue",
- queuereset = "%s just reseted the queue to the main maps",
- -- Simple words
- disabled = "disabled!",
- },
- br = {
- welcome = "Bem-vindo ao <B>#Hardcamp</B>! Digite !info para checar os comandos\n\tReporte quaisquer problemas para Bolodefchoco!",
- info = "Checkpoint:\n\tSe o sistema de checkpoint está ativado, pressione <B>E</B> para marcar um checkpoint e <B>Shift+E</B> para remove-lo.\nAdmin\n\tSe você é um administrador da sala, há alguns comandos que você pode executar:\n\tMapas\n\t\t!next <V>--> Passa o mapa</V>\n\t\t!again <V>--> Reinicia o mapa atual</V>\n\t\t!np @Código <VP>ou</VP> !map @Código <V>--> Carrega um mapa</V>\n\t\t!queue clear <V>--> Limpa a lista de mapas</V>\n\t\t!queue add @Código <V>--> Adiciona um mapa na lista de mapas</V>\n\t\t!queue P3 <VP>ou</VP> P13 <VP>ou</VP> P23 <V>--> Adiciona a rotação inteira de P3 ou P13 ou P23 na lista de mapas</V>\n\tTempo\n\t\t!time TempoEmMinutos <V>--> Define o tempo do mapa atual em TempoEmMinutos</V>\n\t\t!standtime TempoEmMinutos <V>--> Define o tempo de todas as partidas em TempoEmMinutos</V>\n\tOutros\n\t\t<B>Shift+Click</B> sobre um piso para ler suas propriedades\n\t\t!checkpoint [[not] cheese] <V>--> Ativa/Desativa o sistema de checkpoint</V>\n\t\tTecla Delete <V>--> Mata-o</V>",
- skip = "<VP>%s</VP> acabou de passar o mapa!",
- restart = "<VP>%s</VP> acabou de reiniciar o mapa atual!",
- loadmap = "<VP>%s</VP> acabou de carregar o mapa %s!",
- settime = "O tempo foi definido para %s minutos!",
- setstandtime = "O tempo padrão para todas as partidas foram definidas para %s minutos!",
- enabled = "ativado! Pressione <B>E</B> para marcar um checkpoint e <B>Shift+E</B> para remove-lo.",
- queuecleared = "%s acabou de limpar a rotação de mapas",
- queuemapadded = "%s acabou de adicionar o mapa %s na rotação de mapas",
- queueperm = "%s acabou de adicionar a categoria %s na rotação de mapas",
- queuereset = "%s acabou de resetar a rotação de mapas para os mapas principais",
- disabled = "desativado!",
- },
- pl = {
- welcome = "Witaj w <B>#Hardcamp</B>! Wpisz !info na czacie aby sprawdzić jakie są komendy\n\tZgłaszaj wszelkie błędy do Bolodefchoco!",
- info = "Checkpoint:\n\tJeżeli system checkpointów jest włączony, kliknij <B>E</B>, aby ustawić checkpoint i <B>Shift+E</B>, aby go usunąć.\nAdmin\n\tJeżeli jesteś administratorem pokoju, jest kilka komend, które możesz użyć:\n\tMapy\n\t\t!next <V>--> Przełącza mapę</V>\n\t\t!again <V>--> Restartuje mapę</V>\n\t\t!np @Code <VP>albo</VP> !map @Code <V>--> Ładuje mapę</V>\n\t\t!queue clear <V>--> Czyści kolejkę map</V>\n\t\t!queue add @Code <V>--> Dodaję mapę do kolejki</V>\n\t\t!queue P3 <VP>albo</VP> P13 <VP>albo</VP> P23 <V>--> Dodaje wszystkie oficjalne rotacje z permów P3 albo P13 albo P23 do kolejki map</V>\n\tCzas\n\t\t!time CzasWMinutach <V>--> Ustawia czas obecnej mapy na CzasWMinutach</V>\n\t\t!standtime CzasWMinutach <V>--> Ustawia czas dla wszystkich rund na CzasWMinutach</V>\n\tInne\n\t\t<B>Shift+Click</B> na gruncie aby przeczytać jego właściwości\n\t\t!checkpoint [[not] cheese] <V>--> Włącza/Wyłącza system checkpointów</V>\n\t\tKey Delete <V>--> Kills you</V>",
- skip = "<VP>%s</VP> pominął/-ęła mapę!",
- restart = "<VP>%s</VP> zrestartował/-a mapę!",
- loadmap = "<VP>%s</VP> załadował/-a mapę %s!",
- settime = "Czas został ustawiony na %s minut!",
- setstandtime = "Standardowy czas dla wszystkich map został ustawiony na %s minut!",
- enabled = "włączony! Kliknij <B>E</B>, aby ustawić checkpoint i <B>Shift+E</B>, aby go usunąć.",
- queuecleared = "%s just cleared the map queue",
- queuemapadded = "%s just added the map %s to the map queue",
- queueperm = "%s just added the category %s to the map queue",
- queuereset = "%s just reseted the queue to the main maps",
- disabled = "wyłączony!",
- },
- },
- langue = "",
- --[[ Data ]]--
- info = {},
- --[[ Maps ]]--
- maps = {},
- map = function()
- mode.hardcamp.maps = {6501305,6118143,2604997,2836937,6921682,3339586,5776126,5678468,6531399,5847160,5745650,7091808,7000003,6999993,4559999,4784241,3883780,4976520,4854044,6374076,3636206,6793803,4499335,4694197,5485847,6258690,3938895,1719709,4209243,6550335,3866650,3999455,4095418,4523127,1964971,1554670,4423047,764650,4883346,2978216,1947288,7025830,7108857,4766627,5888889,6782978,5699275,6422459,2634659,4808290,3620953,2973289,2604643,6591698,7134487,7054821,7159725,3737744,6933187,6864581,4701337,6631702,6761156,4212122,4160675,4623227,5191670,1132272,2781845,7167027,4834444,3734991,7037760,6502657,6469688,6092666,2749928,7175796,7142063,7167539,7173296,6995540,7151000,3931358,3374686,6324891,3704015,3937060,2429057,7192029,7192034,7192689,3883883,7192031,7192035,4559999,7189846,7192152,7227889,7194815,7192039,7192051,6911697,7106057,7196825,7205876,7228130,1533335,6931020,7066666}
- end,
- --[[ Settings ]]--
- groundsData = {},
- mapData = {},
- standardTime = 6,
- checkpoint = false,
- respawnCheese = false,
- --[[ Leaderboard ]]--
- rank = function(players,fromValue,showPos,showPoints,pointsName,lim)
- local p,rank = {},""
- fromValue,lim = fromValue or {tfm.get.room.playerList,"score"},tonumber(lim) or 100
- for n in next,players do
- p[#p+1] = {name=n,v=fromValue[1][n][fromValue[2]]}
- end
- tablesort(p,function(f,s) return f.v>s.v end)
- for o,n in next,p do
- if o <= lim then
- rank = rank .. (showPos and "<J>"..o..". " or "") .. "<V>" .. n.name .. (showPoints and " <BL>- <VP>" .. n.v .. " "..(pointsName or "points") .."\n" or "\n")
- end
- end
- return rank
- end,
- --[[ Init ]]--
- reset = function()
- -- Data
- mode.hardcamp.info = {}
- end,
- init = function()
- -- Settings
- mode.hardcamp.respawnCheese = system.miscAttrib == 1
- -- Init
- for _,f in next,{"AutoShaman","AutoScore","AutoTimeLeft","AutoNewGame","PhysicalConsumables","AfkDeath"} do
- tfm.exec["disable"..f]()
- end
- tfm.exec.setAutoMapFlipMode(false)
- mode.hardcamp.map()
- tfm.exec.newGame(tablerandom(mode.hardcamp.maps))
- -- Auto Admin
- system.roomAdmins.Mquk = true
- end,
- --[[ Events ]]--
- -- NewGame
- eventNewGame = function()
- tfm.exec.setGameTime(mode.hardcamp.standardTime * 60)
- mode.hardcamp.groundsData = {}
- mode.hardcamp.mapData = {}
- for k,v in next,mode.hardcamp.info do
- v.cheese = false
- v.checkpoint = {false,0,0,false}
- ui.removeTextArea(1,n)
- end
- local xml = tfm.get.room.xmlMapInfo.xml
- if xml then
- local grounds = stringmatch(xml,"<S>(.-)</S>")
- local properties = stringmatch(xml,"<C><P (.-)/>.*<Z>")
- if properties then
- mode.hardcamp.mapData = {
- width = stringmatch(properties,'L="(%d+)"') or 800,
- heigth = stringmatch(properties,'H="(%d+)"') or 400,
- }
- else
- mode.hardcamp.mapData = {
- width = 800,
- heigth = 400,
- }
- end
- local data = {}
- local foo = function(attributes)
- data[#data + 1] = attributes
- end
- stringgsub(grounds,"<S (.-)/>",foo)
- for i = 1,#data do
- mode.hardcamp.groundsData[i] = {}
- local type = stringmatch(data[i],'T="(%d+)"')
- mode.hardcamp.groundsData[i].type = type and tonumber(type) or -1
- local x = stringmatch(data[i],'X="(%d+)"')
- mode.hardcamp.groundsData[i].x = x and tonumber(x) or 0
- local y = stringmatch(data[i],'Y="(%d+)"')
- mode.hardcamp.groundsData[i].y = y and tonumber(y) or 0
- local width = stringmatch(data[i],'L="(%d+)"')
- mode.hardcamp.groundsData[i].width = width and tonumber(width) or 0
- local heigth = stringmatch(data[i],'H="(%d+)"')
- mode.hardcamp.groundsData[i].heigth = heigth and tonumber(heigth) or 0
- local info = stringmatch(data[i],'P="(.*)"')
- info = stringsplit(info,"[^,]+")
- mode.hardcamp.groundsData[i].friction = info[3] and tonumber(info[3]) or .3
- mode.hardcamp.groundsData[i].restitution = info[3] and tonumber(info[4]) or .2
- mode.hardcamp.groundsData[i].angle = info[3] and tonumber(info[5]) or 0
- end
- end
- end,
- -- NewPlayer
- eventNewPlayer = function(n)
- if not mode.hardcamp.info[n] then
- mode.hardcamp.info[n] = {
- shift = false,
- checkpoint = {false,0,0,false},
- cheese = false,
- }
- end
- tfm.exec.respawnPlayer(n)
- system.bindMouse(n,true)
- for i = 1,2 do
- system.bindKeyboard(n,16,i==1,true)
- system.bindKeyboard(n,stringbyte("K"),i==1,true)
- end
- system.bindKeyboard(n,stringbyte("E"),true,true)
- system.bindKeyboard(n,46,true,true) -- Delete key
- tfm.exec.chatMessage("<T>" .. system.getTranslation("welcome") .. "\n\t<CEP>/w Mquk #bootcamp+ @mapCode",n)
- ui.banner("15d75ac6aa9",120,100,n)
- end,
- -- Mouse
- eventMouse = function(n,x,y)
- if mode.hardcamp.info[n].shift then
- for i = #mode.hardcamp.groundsData,1,-1 do
- local g = mode.hardcamp.groundsData[i]
- local rad = mathrad(g.angle)
- local ax = {mathcos(rad),mathsin(rad)}
- local gX = g.x + ax[1] * (x - g.x) - ax[2] * (y - g.y)
- local gY = g.y + ax[2] * (x - g.x) + ax[1] * (y - g.y)
- if (g.type == 13 and mathpythag(x,y,g.x,g.y,g.width/2) or (mathabs(gX - g.x) < g.width/2 and mathabs(gY - g.y) < g.heigth/2)) then
- local properties = {"Type","ID","X","Y","Heigth","Width","Friction","Restitution","Angle"}
- local info = ""
- for k,v in next,properties do
- info = info .. stringformat("<N>%s : <V>%s\n",v,(v == "ID" and i or v == "Type" and (({[0] = "Unknown","Wood","Ice","Trampoline","Lava","Chocolate","Earth","Grass","Sand","Cloud","Water","Stone","Snow","Rectangle","Circle","Spiderweb"})[g.type + 1]) or tostring(g[stringlower(v)])))
- end
- local mapW = tonumber(mode.hardcamp.mapData.width)
- local mapH = tonumber(mode.hardcamp.mapData.heigth)
- ui.addTextArea(0,info,n,(x + 150 <= mapW and x) or (x < 0 and 0) or (mapW - 150),(y + 180 <= mapH and y > 20 and y) or (y < 20 and 25) or (mapH - 180),nil,nil,nil,nil,.8,false)
- end
- end
- else
- ui.removeTextArea(0,n)
- end
- end,
- -- Keyboard
- eventKeyboard = function(n,k,d,x,y)
- if k == 16 then
- mode.hardcamp.info[n].shift = d
- elseif k == stringbyte("E") and mode.hardcamp.checkpoint then
- if mode.hardcamp.info[n].shift then
- mode.hardcamp.info[n].checkpoint = {false,0,0,mode.hardcamp.info[n].checkpoint[4]}
- ui.removeTextArea(1,n)
- else
- mode.hardcamp.info[n].checkpoint = {true,x,y,true}
- ui.addTextArea(1,"",n,x-5,y-5,10,10,0x56A75A,0x56A75A,.5,true)
- end
- elseif k == stringbyte("K") then
- if d then
- ui.addTextArea(2,mode.hardcamp.rank(tfm.get.room.playerList,{tfm.get.room.playerList,"score"},true,true,"points",20),n,5,30,nil,200,nil,nil,.8,true)
- else
- ui.removeTextArea(2,n)
- end
- elseif k == 46 then
- tfm.exec.killPlayer(n)
- end
- end,
- -- ChatCommand
- eventChatCommand = function(n,c)
- local p = stringsplit(c,"[^%s]+",stringlower)
- if p[1] == "info" then
- tfm.exec.chatMessage("<T>" .. system.getTranslation("info"),n)
- else
- if system.roomAdmins[n] then
- if p[1] == "next" and os.time() > system.newGameTimer then
- tfm.exec.newGame(tablerandom(mode.hardcamp.maps))
- tfm.exec.chatMessage("<T>• " .. stringformat(system.getTranslation("skip"),n))
- elseif p[1] == "again" and os.time() > system.newGameTimer then
- tfm.exec.newGame(tfm.get.room.currentMap)
- tfm.exec.chatMessage("<T>• " .. stringformat(system.getTranslation("restart"),n))
- elseif (p[1] == "np" or p[1] == "map") and os.time() > system.newGameTimer then
- tfm.exec.newGame(p[2])
- tfm.exec.chatMessage("<T>• " .. stringformat(system.getTranslation("loadmap"),n,stringfind(p[2],"@") and p[2] or "@"..p[2]))
- elseif p[1] == "time" then
- tfm.exec.setGameTime(p[2] * 60)
- tfm.exec.chatMessage(stringformat(system.getTranslation("settime"),p[2]))
- elseif p[1] == "standtime" then
- p[2] = p[2] and tonumber(p[2]) or 6
- if p[2] > 0 and p[2] < 10 then
- mode.hardcamp.standardTime = p[2]
- tfm.exec.chatMessage(stringformat(system.getTranslation("setstandtime",p[2])))
- end
- elseif p[1] == "checkpoint" then
- local attribute = false
- if p[2] then
- attribute = true
- if p[2] == "not" and p[3] and p[3] == "cheese" then
- mode.hardcamp.respawnCheese = false
- elseif p[2] == "cheese" then
- mode.hardcamp.respawnCheese = true
- else
- attribute = false
- end
- end
- if not (mode.hardcamp.checkpoint and attribute) then
- mode.hardcamp.checkpoint = not mode.hardcamp.checkpoint
- tfm.exec.chatMessage("<T>Checkpoint " .. system.getTranslation(mode.hardcamp.checkpoint and "enabled" or "disabled"))
- if not mode.hardcamp.checkpoint then
- ui.removeTextArea(1,nil)
- for k,v in next,mode.hardcamp.info do
- v.checkpoint = {false,0,0,v.checkpoint[4]}
- end
- if system.miscAttrib ~= 1 then
- mode.hardcamp.respawnCheese = false
- end
- for k,v in next,mode.hardcamp.info do
- v.cheese = false
- end
- end
- end
- elseif p[1] == "queue" then
- if p[2] == "clear" then
- mode.hardcamp.maps = {}
- tfm.exec.chatMessage("• " .. stringformat(system.getTranslation("queuecleared"),n))
- elseif p[2] == "add" then
- mode.hardcamp.maps[#mode.hardcamp.maps + 1] = p[3]
- tfm.exec.chatMessage("• " .. stringformat(system.getTranslation("queuemapadded"),n,stringfind(p[3],"@") and p[3] or "@"..p[3]))
- elseif p[2] and stringsub(p[2],1,1) == "p" then
- if p[2] == "p3" or p[2] == "p13" or p[2] == "p23" then
- mode.hardcamp.maps[#mode.hardcamp.maps + 1] = "#" .. stringsub(p[2],2)
- tfm.exec.chatMessage("• " .. stringformat(system.getTranslation("queueperm"),n,stringupper(p[2])))
- end
- else
- mode.hardcamp.map()
- tfm.exec.chatMessage("• " .. stringformat(system.getTranslation("queuereset"),n))
- end
- end
- end
- end
- end,
- -- Loop
- eventLoop = function()
- if _G.leftTime < 1 then
- tfm.exec.newGame(tablerandom(mode.hardcamp.maps))
- end
- end,
- -- PlayerDied
- eventPlayerDied = function(n)
- system.newTimer(function()
- tfm.exec.respawnPlayer(n)
- if mode.hardcamp.checkpoint and mode.hardcamp.info[n].checkpoint[1] then
- tfm.exec.movePlayer(n,mode.hardcamp.info[n].checkpoint[2],mode.hardcamp.info[n].checkpoint[3])
- end
- if mode.hardcamp.checkpoint and mode.hardcamp.info[n].cheese and mode.hardcamp.respawnCheese then
- tfm.exec.giveCheese(n)
- end
- end,1500,false)
- end,
- -- PlayerWon
- eventPlayerWon = function(n,t,time)
- mode.hardcamp.info[n].cheese = false
- mode.hardcamp.info[n].checkpoint = {false,0,0,mode.hardcamp.info[n].checkpoint[4]}
- ui.removeTextArea(1,n)
- mode.hardcamp.eventPlayerDied(n)
- tfm.exec.setPlayerScore(n,1,true)
- tfm.exec.chatMessage(stringformat("<ROSE>%s (%ss <PT>(%scheckpoint)</PT>)",n,time/100,mode.hardcamp.info[n].checkpoint[4] and "" or "no "),n)
- end,
- -- PlayerGetCheese
- eventPlayerGetCheese = function(n)
- if mode.hardcamp.checkpoint and mode.hardcamp.respawnCheese then
- mode.hardcamp.info[n].cheese = true
- end
- end,
- }
- --[[ ModeChanged ]]--
- system.objects = {
- image = {},
- textarea = {}
- }
- eventModeChanged = function()
- -- Remove content
- for k in next,system.objects.image do
- tfm.exec.removeImage(k)
- end
- for k in next,system.objects.textarea do
- ui.removeTextArea(k,nil)
- end
- system.objects = {
- image = {},
- textarea = {}
- }
- ui.addPopup(0,0,"",nil,-1500,-1500)
- -- Unbind keyboard and mouse, also normalize color name and scores
- for k in next,tfm.get.room.playerList do
- for i = 0,255 do
- for v = 0,1 do
- system.bindKeyboard(k,i,v == 0,false)
- end
- end
- system.bindMouse(k,false)
- tfm.exec.setNameColor(k,-1)
- tfm.exec.setPlayerScore(k,0)
- end
- -- Set admin back
- system.roomAdmins = system.setAdmins()
- -- Reset settings
- tfm.exec.snow(0)
- for k,v in next,{"AutoScore","WatchCommand","AutoNewGame","AutoShaman","AllShamanSkills","MortCommand","DebugCommand","MinimalistMode","AfkDeath","PhysicalConsumables","AutoTimeLeft"} do
- tfm.exec["disable" .. v](false)
- end
- tfm.exec.setAutoMapFlipMode()
- tfm.exec.setRoomMaxPlayers(25)
- tfm.exec.setRoomPassword("")
- end
- --[[ Events ]]--
- --[[ eventLoop ]]--
- events.eventLoop = function(currentTime,leftTime)
- _G.currentTime = normalizeTime(currentTime / 1e3)
- _G.leftTime = normalizeTime(leftTime / 1e3)
- end
- --[[ eventNewPlayer ]]--
- events.eventNewPlayer = function(n)
- tfm.exec.lowerSyncDelay(n)
- if system.officialMode[2] ~= "" then
- tfm.exec.chatMessage(system.officialMode[2],n)
- end
- if system.playerMessage ~= "" then
- tfm.exec.chatMessage("<J>" .. system.playerMessage,n)
- end
- end
- --[[ eventChatCommand ]]--
- events.eventChatCommand = function(n,c)
- if system.isPlayer(n) then
- system.disableChatCommandDisplay(c,true)
- local p = stringsplit(c,"[^%s]+",stringlower)
- disableChatCommand(p[1])
- if module._FREEACCESS[n] then
- if p[1] == "refresh" and (module._FREEACCESS[n] > 1 or not system.isRoom) then
- eventModeChanged()
- system.init(true)
- return
- end
- if p[1] == "room" and (module._FREEACCESS[n] > 1 or not system.isRoom) then
- local room = tonumber(p[2]) or 0
- if _G["eventChatCommand"] and system.roomNumber ~= room then
- system.roomNumber = room
- eventChatCommand(n,"refresh")
- end
- return
- end
- if p[1] == "setmisc" and p[2] and (module._FREEACCESS[n] > 1 or not system.isRoom) then
- system.miscAttrib = tonumber(p[2]) or 0
- system.miscAttrib = mathsetLim(system.miscAttrib,0,99)
- if p[3] == "true" then
- eventChatCommand(n,"refresh")
- end
- return
- end
- if p[1] == "load" and (module._FREEACCESS[n] > 2 or not system.isRoom) then
- if os.time() > system.modeChanged and os.time() > system.newGameTimer then
- if system.getGameMode(p[2],true) then
- system.init(system.isRoom)
- end
- end
- return
- end
- end
- if p[1] == "module" then
- p[2] = stringupper(p[2] or "")
- if module["_" .. p[2]] then
- if p[2] == "FREEACCESS" then
- if p[3] then
- p[3] = stringnick(p[3])
- tfm.exec.chatMessage(p[3] .. " ~> " .. (module._FREEACCESS[p[3]] or 0),n)
- else
- tfm.exec.chatMessage(p[2] .. " : ",n)
- for k,v in pairsByIndexes(module._FREEACCESS,function(a,b) return module._FREEACCESS[a] > module._FREEACCESS[b] end) do
- tfm.exec.chatMessage(stringformat("%s ~> %s",k,v),n)
- end
- end
- else
- tfm.exec.chatMessage(p[2] .. " : " .. tableconcat(tableturnTable(module["_" .. p[2]]),"\n",function(k,v)
- return v
- end),n)
- end
- else
- 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)
- end
- return
- end
- if p[1] == "modes" then
- tfm.exec.chatMessage(tableconcat({tableunpack(system.submodes,2)},"\n",function(k,v)
- return stringformat("~> /room #%s%s@%s#%s",module._NAME,mathrandom(0,999),n,v)
- end),n)
- return
- end
- if p[1] == "stop" and system.roomAdmins[n] then
- system.exit()
- end
- if p[1] == "admin" then
- tfm.exec.chatMessage(tableconcat(system.roomAdmins,", ",tostring),n)
- return
- end
- if p[1] == "adm" and p[2] and (system.roomAdmins[n] or (module._FREEACCESS[n] and module._FREEACCESS[n] > 2)) then
- if tablefind({"true","false"},p[3]) then
- local pl = stringnick(p[2])
- system.roomAdmins[pl] = (module._FREEACCESS[pl] and true) or p[3] == "true" or nil
- end
- return
- end
- if p[1] == "setroomlanguage" and p[2] and (system.roomAdmins[n] or (module._FREEACCESS[n] and module._FREEACCESS[n] > 2)) then
- if mode[system.gameMode].translations[p[2]] then
- system.roomLanguage = p[2]
- mode[system.gameMode].langue = system.roomLanguage
- end
- return
- end
- if p[1] == "me" then
- local commands = {
- [0] = {},
- [1] = {"!refresh (tribe house)","!setMisc [number] [refresh] (tribe house)","!room [number] (tribe house)","!load [mode] (tribe house)"},
- [2] = {"!refresh","!setMisc [number] [refresh]","!room [number]","!load [mode] (tribe house)"},
- [3] = {"!refresh","!setMisc [number] [refresh]","!room [number]","!load [mode]"}
- }
- local access = module._FREEACCESS[n] or 0
- if system.roomAdmins[n] then
- for k,v in next,{"!stop","!adm [playerName] [true/false]","!setRoomLanguage [language]"} do
- commands[access][#commands[access] + 1] = v
- end
- end
- 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)
- return
- end
- end
- end
- --[[ RoomSettings ]]--
- system.roomSettings = {
- -- 0 = Only the first value
- -- 1 = All the text
- ["@"] = {0,function(n)
- if n and #n > 2 then
- system.roomAdmins[stringnick(n)] = true
- end
- end},
- ["*"] = {0,function(id)
- system.miscAttrib = tonumber(id) or 1
- system.miscAttrib = mathsetLim(system.miscAttrib,1,99)
- end},
- ["#"] = {0,function(name)
- if name then
- local game = system.getGameMode(name)
- if not game then
- system.gameMode = module._NAME
- end
- end
- end},
- [":"] = {1,function(text)
- if text and #text > 0 then
- system.playerMessage = stringsub(text,1,40)
- end
- end},
- ["!"] = {0,function(langue)
- if langue and #langue > 0 then
- system.roomLanguage = stringlower(langue)
- end
- end}
- }
- system.setRoom = function()
- if system.isRoom and system.roomAttributes then
- local chars = ""
- for k in next,system.roomSettings do
- chars = chars .. k
- end
- for char,value in stringgmatch(system.roomAttributes,"(["..chars.."])([^"..chars.."]+)") do
- for k,v in next,system.roomSettings do
- if k == char then
- v[2](v[1] == 0 and stringmatch(value,"[^%s]+") or value)
- break
- end
- end
- end
- local officialModes = {
- {"vanilla","<VP>Enjoy your vanilla (: .. okno"},
- {"survivor","<R>Aw, you cannot play survivor on #grounds"},
- {"racing","<CH>Uh, racing? Good luck!"},
- {"music","<BV>Music? Nice choice! Why don't you try a rock'n'roll?"},
- {"bootcamp","<PT>Bootcamp? Ok. This is unfair and your data won't be saved out of the room."},
- {"defilante","<R>Aw, you cannot play defilante on #grounds"},
- {"village","<R>You cannot play village on #grounds. Please, change your room."},
- }
- for k,v in next,officialModes do
- if stringfind(stringlower(system.roomAttributes),v[1]) then
- system.officialMode = {v[1],v[2]}
- break
- end
- end
- end
- end
- --[[ Initialize ]]--
- execute = {}
- system.setRoom()
- system.init = function(refresh)
- 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
- local e = "event" .. event
- local found = false
- for k,v in next,mode[system.gameMode] do
- if k == e then
- execute[e] = v
- found = true
- break
- end
- end
- if not found then
- execute[e] = function() end
- end
- _G[e] = function(...)
- if events[e] then
- events[e](...)
- end
- execute[e](...)
- end
- end
- if refresh then
- if mode[system.gameMode].reset then
- mode[system.gameMode].reset()
- end
- end
- normalizeTranslation()
- mode[system.gameMode].init()
- if _G["eventNewPlayer"] then
- tableforeach(tfm.get.room.playerList,eventNewPlayer)
- end
- end
- system.init()
Add Comment
Please, Sign In to add comment