Advertisement
Bolodefchoco_LUAXML

[Event] Mapmaker

Feb 27th, 2017
256
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 12.14 KB | None | 0 0
  1. --[[ Title ]]--
  2. title = {
  3.     [1] = "titre_mapmaker",
  4. }
  5.  
  6. --[[ Translation ]]--
  7. system.translation = {
  8.     en = {
  9.         intro = "Are you good in counting? Why don't you try to count how many grounds there are in this map? !Try it!",
  10.         stats = "Stats were disabled in this round.",
  11.         credits = "Event developed by Bolodefchoco.",
  12.         currentScore = "You currently have %s points!",
  13.         nochances = "You spent all your chances!",
  14.         troll = "You've completed the event! Why don't you troll your roommates saying random commands? Hehe",
  15.         enigma = "What ground am I?",
  16.         grounds = {
  17.             {"Wood","I am derived from trees"},
  18.             {"Ice","Polar bears love me"},
  19.             {"Trampoline","You see me in circus"},
  20.             {"Lava","I killed Pompeii"},
  21.             {"Chocolate","I am delicious"},
  22.             {"Earth","I'm one of the 4 elements"},
  23.             {"Grass","I am always greener on the other side"},
  24.             {"Sand","You often put your coconut on me"},
  25.             {"Cloud","\"You believe, you can fly, you can touch\".. me"},
  26.             {"Water","2 molecules of hydrogen and 1 molecule of oxygen"},
  27.             {"Stone","Sticks and me's"},
  28.             {"Snow","I can be an angel or a man"},
  29.             {"Rectangle","My area ignores two sides"},
  30.             {"Circle","3.14 is my number"},
  31.             {"Spiderweb","The Incy Wincy uses me"},
  32.         },
  33.     },
  34.     br = {
  35.         intro = "Você é bom em contar? Por que você não tenta contar quantos pisos existem neste mapa? !Prove!",
  36.         stats = "Estatísticas foram desativadas nesta partida.",
  37.         credits = "Evento desenvolvido por Bolodefchoco.",
  38.         currentScore = "Você atualmente tem %s pontos!",
  39.         nochances = "Você gastou todas as suas chances!",
  40.         troll = "Você completou o evento! Por que não trolla seus colegas de sala dizendo comandos aleatórios? Hehe",
  41.         enigma = "Que piso sou eu?",
  42.         grounds = {
  43.             {"Madeira","Sou derivada das árvores"},
  44.             {"Gelo","Ursos polares me amam"},
  45.             {"Trampolim","Você me vê no circo"},
  46.             {"Lava","Eu matei Pompéia"},
  47.             {"Chocolate","Eu sou delicioso"},
  48.             {"Terra","Eu sou um dos 4 elementos"},
  49.             {"Grama","Eu sou sempre mais verde do outro lado da cerca"},
  50.             {"Areia","Você sempre põe seu coco em mim"},
  51.             {"Nuvem","\"You believe, you can fly, you can touch\".. eu"},
  52.             {"Água","2 moléculas de hidrogênio e 1 molécula de oxigênio"},
  53.             {"Pedra","Paus e Eus"},
  54.             {"Neve","Eu posso ser um anjo ou um boneco"},
  55.             {"Retângulo","Minha área ignora dois lados"},
  56.             {"Circulo","3,14 é meu número"},
  57.             {"Teia de Aranha","A Dona Aranha me usa"},
  58.         },
  59.     },
  60.     es = {
  61.         intro = "¿Eres bueno contando? ¿Por qué no intentas contar cuántos suelos hay en este mapa? ¡!Inténtalo!",
  62.         stats = "Las estadísticas fueron deshabilitadas en esta ronda.",
  63.         credits = "Evento desarrollado por Bolodefchoco.",
  64.         currentScore = "¡Actualmente tienes %s puntos!",
  65.         nochances = "¡Gastaste todas tus oportunidades!",
  66.         troll = "¡Has completado el evento! ¿Por qué no trolleas a tus compañeros de sala diciendo comandos al azar? Jeje",
  67.         enigma = "¿Qué suelo soy?",
  68.         grounds = {
  69.             {"Madera","Soy derivado de los árboles"},
  70.             {"Hielo","Los osos polares me aman"},
  71.             {"Trampolín","Me ves en los circos"},
  72.             {"Lava","Maté a Pompeya"},
  73.             {"Chocolate","Soy delicioso"},
  74.             {"Tierra","Soy uno de los cuatro elementos"},
  75.             {"Hierba","Yo, la mala, nunca muero"},
  76.             {"Arena","Con frecuencia pones tu coco sobre mi"},
  77.             {"Nube","\"You believe, you can fly, you can touch\".. me"},
  78.             {"Agua","2 moléculas de hidrógeno y 1 de oxígeno"},
  79.             {"Piedra","Tropezar dos veces conmigo"},
  80.             {"Nieve","Puedo ser un ángel o un hombre"},
  81.             {"Rectángulo","Mi área ignora dos lados"},
  82.             {"Círculo","3.14 es mi número"},
  83.             {"Telaraña","Incy Wincy me usa"},
  84.         },
  85.     },
  86.     ro = {
  87.         intro = "Ești bun la numărat? De ce nu încerci să numeri câte terenuri sunt pe această hartă? Încearcă!",
  88.         stats = "Statisticile sunt dezactivate în această rundă.",
  89.         credits = "Evenimentul a fost creat de Bolodefchoco.",
  90.         currentScore = "În acest moment ai % puncte!",
  91.         nochances = "Ți-ai folosit toate șansele!",
  92.         troll = "Ai terminat deja evenimentul! De ce nu păcălești ceilalți jucători de pe sală cu niște comenzi aleatoare? Hehe",
  93.         enigma = "Pe ce teren mă aflu?",
  94.         grounds = {
  95.             {"Lemn","Sunt făcut din copaci"},
  96.             {"Gheață","Urșii polari mă iubesc"},
  97.             {"Trambulină","Mă poți vedea la circ"},
  98.             {"Lavă","Am distrus Pompeiul"},
  99.             {"Ciocolată","Sunt delicioasă"},
  100.             {"Pământ","Sunt unul dintre cele patru elemente"},
  101.             {"Iarbă","Sunt întotdeauna mai verde la vecini"},
  102.             {"Nisip","Mă aflu în clepsidră"},
  103.             {"Nor","Cu capul în ..."},
  104.             {"Apă","Două molecule de hidrogen și o moleculă de oxigen"},
  105.             {"Piatră","Se ridică de pe inimă"},
  106.             {"Zăpadă","Pot să fiu un înger sau un om"},
  107.             {"Dreptunghi","Sunt un pătrat mai alungit"},
  108.             {"Cerc","3.14 este numărul meu preferat"},
  109.             {"Pânză de păianjen","Sunt folosită de Spider-Man"},
  110.         },
  111.     },
  112.     ar = {},
  113.     fr = {
  114.         intro = "Savez-vous compter ? Pourquoi n'essayeriez-vous pas de compter combien il y a de sols sur cette carte, allez hop hop hop !",
  115.         stats = "Les statistiques ont été désactivées pour cette partie.",
  116.         credits = "Développé par Bolodefchoco.",
  117.         currentScore = "Vous avez actuellement %s points!",
  118.         nochances = "Vous avez épuisé toutes vos chances.",
  119.         troll = "Vous avez terminé ! Trollez à votre tour vos petits camarades de jeu. Haha ^_^",
  120.         enigma = "Quel sol suis-je?",
  121.         grounds = {
  122.             {"Bois","Je suis le squelette de la forêt"},
  123.             {"Glace","Je suis piétiné par les pingouins"},
  124.             {"Trampoline","Je suis idéal pour les acrobaties"},
  125.             {"Lave","Je suis détesté à Pompéi"},
  126.             {"Chocolat","Je suis délicieux"},
  127.             {"Terre","Je suis la mère de toute chose"},
  128.             {"Herbe","Je suis chouchouté par les golfeurs"},
  129.             {"Sable","Je côtoie coquillages et noix de coco"},
  130.             {"Nuage","J'ai souvent votre tête en moi"},
  131.             {"Eau","Je suis également connu sous le nom de H2O"},
  132.             {"Pierre","Je suis aussi un prénom"},
  133.             {"Neige","Je suis fâchée avec le soleil"},
  134.             {"Rectangle","J'ai horreur des arrondis"},
  135.             {"Rond","Je ne jure que par pi"},
  136.             {"Toile d'Araignée","Je n'ai aucun lien avec SpiderCochon"},
  137.         },
  138.     },
  139.     pl = {
  140.         intro = "Jesteś dobry w liczeniu? Czemu nie spróbujesz ile jest gruntów na tej mapie? ! Dawaj!",
  141.         stats = "Statystyki są wyłączone w tej rundzie.",
  142.         credits = "Event stworzony przez Bolodefchoco.",
  143.         currentScore = "Masz %s punktów!",
  144.         nochances = "Zmarnowałeś wszystkie swoje szanse!",
  145.         troll = "Zakończyłeś event! Czemu nie spróbujesz strollować swoich towarzyszy w pokoju pisząc różne komendy? Hehe",
  146.         enigma = "Jakim gruntem jestem?",
  147.         grounds = {
  148.             {"Drewno","Jestem z drzewa"},
  149.             {"Lód","Misie polarne mnie kochają"},
  150.             {"Trampolina","Widzisz mnie w cyrku"},
  151.             {"Lawa","Ja zniszczyłem Pompeje"},
  152.             {"Czekolada","Jestem smaczna"},
  153.             {"Ziemia","Jestem jedna z czterech elementów"},
  154.             {"Trawa","Jestem zawsze bardziej zielona po drugiej stronie"},
  155.             {"Piasek","Często kładziesz kokos na mnie"},
  156.             {"Chmura","\"You believe, you can fly, you can touch\".. mnie"},
  157.             {"Woda","2 cząsteczki wodoru i 1 cząsteczka tlenu"},
  158.             {"Kamień","Patyki i ja"},
  159.             {"Śnieg","Mogę być śniegiem albo człowiekiem"},
  160.             {"Trójkąt","Moje pole ignoruje dwa boki"},
  161.             {"Koło","3.14 w mojej liczbie"},
  162.             {"Pajęczyna","Incy Wincy mnie używa"},
  163.         },
  164.     },
  165. }
  166. system.translation.pt = system.translation.br
  167.  
  168. system.communityTranslation = system.translation.en
  169. for k,v in next,system.translation do
  170.     if k == tfm.get.room.community then
  171.         system.communityTranslation = v
  172.         break
  173.     end
  174. end
  175.  
  176. --[[ Data ]]--
  177. serialization = function(x)
  178.     if type(x) == "table" then
  179.         local t = x
  180.         local str = ""
  181.         for index,value in next,t do
  182.             local prefix,tbOption = (type(value)=="string" and "_@" or type(value)=="boolean" and "_!" or type(value)=="number" and "_#" or type(value)=="table" and "_%" or ""),(type(value)~="table" and tostring(value) or "+&"..serialization(value):gsub(";","?").."&-")
  183.             str = str .. ':' .. tostring(index) .. prefix .. tbOption .. ";"
  184.         end
  185.         return str
  186.     elseif type(x) == "string" then
  187.         local s = x
  188.         local list = {}
  189.         for str in s:gmatch("(.-);") do
  190.             local varName,valueType,value = str:match(':(.-)_(%p)(.+)')
  191.             if varName~=nil then
  192.                 varName = tonumber(varName) or varName
  193.                 if valueType == "@" then
  194.                     list[varName] = tostring(value)
  195.                 elseif valueType == "!" then
  196.                     list[varName] = value=="true"
  197.                 elseif valueType == "#" then
  198.                     list[varName] = tonumber(value)
  199.                 elseif valueType == "%" then
  200.                     list[varName] = serialization(value:gsub("+&",""):gsub("&-",""):gsub("%?",";"))
  201.                 end
  202.             end
  203.         end
  204.         return list
  205.     end
  206. end
  207.  
  208. eventPlayerDataLoaded = function(n,d)
  209.     if d ~= "" and d:find(":eventMapmakerScore") then
  210.         info[n].db = serialization(d)
  211.     else
  212.         system.savePlayerData(n,serialization(info[n].db))
  213.     end
  214.     info[n].dataLoaded = true
  215.     tfm.exec.chatMessage("<font color='#3EC0E3'>[•] "..system.communityTranslation.intro,n)
  216.     tfm.exec.chatMessage("<CE>[•] "..system.communityTranslation.currentScore:format(info[n].db.eventMapmakerScore),n)
  217.     if info[n].db.eventMapmakerScore > 29 then
  218.         if not info[n].db.eventMapmakerTitle then
  219.             tfm.exec.chatMessage("<CE>[•] "..system.communityTranslation.grounds[info[n].db.eventMapmakerEnigma][2]..". "..system.communityTranslation.enigma,n)
  220.         else
  221.             tfm.exec.chatMessage("<CE>[•] "..system.communityTranslation.grounds.troll,n)
  222.         end
  223.     end
  224. end
  225.  
  226. --[[ eventNewGame ]]--
  227. system.grounds = 0
  228.  
  229. info = {}
  230. eventNewGame = function()
  231.     system.grounds = 0
  232.     for n,p in next,tfm.get.room.playerList do
  233.         info[n] = {
  234.             db = {
  235.                 eventMapmakerScore = 0,
  236.                 eventMapmakerEnigma = math.random(#system.translation.en.grounds),
  237.                 eventMapmakerTitle = false
  238.             },
  239.             dataLoaded = false,
  240.             chance = 2,
  241.             mapDone = false,
  242.         }
  243.         system.loadPlayerData(n)
  244.     end
  245.     tfm.exec.chatMessage("<ROSE>[•] ".. system.communityTranslation.stats)
  246.     local xml = tfm.get.room.xmlMapInfo.xml:match("<S>(.*)</S>")
  247.     xml:gsub("<S ",function()
  248.         system.grounds = system.grounds + 1
  249.     end)
  250. end
  251.  
  252. --[[ chatCommand ]]--
  253. deactivateAccents=function(str)
  254.     local letters = {a = {"á","â","à","å","ã","ä"},e = {"é","ê","è","ë"},i = {"í","î","ì","ï"},o = {"ó","ô","ò","õ","ö"},u = {"ú","û","ù","ü"}}
  255.     for k,v in next,letters do
  256.         for i = 1,#v do
  257.             str = str:gsub(v[i],tostring(k))
  258.         end
  259.     end
  260.     return str
  261. end
  262. eventChatCommand = function(n,c)
  263.     if info[n].dataLoaded then
  264.         info[n].chance = info[n].chance - 1
  265.         if info[n].chance > 0 then
  266.             if info[n].db.eventMapmakerScore < 30 then
  267.                 if c == tostring(system.grounds) then
  268.                     info[n].chance = 0
  269.                     info[n].mapDone = true
  270.                     info[n].db.eventMapmakerScore = info[n].db.eventMapmakerScore + 1
  271.                     tfm.exec.chatMessage("<VP>:)",n)
  272.                     --system.savePlayerData(n,serialization(info[n].db))
  273.                 else
  274.                     if not info[n].mapDone then
  275.                         tfm.exec.chatMessage("<R>:(",n)
  276.                     end
  277.                 end
  278.             else
  279.                 if not info[n].db.eventMapmakerTitle then
  280.                     c = deactivateAccents(c:gsub(" ","")):lower()
  281.                     local groundName = system.communityTranslation.grounds[info[n].db.eventMapmakerEnigma][1]
  282.                     groundName = deactivateAccents(groundName:gsub(" ","")):lower()
  283.                     if groundName == c then
  284.                         --system.giveEventGift(n,title[1])
  285.                         info[n].db.eventMapmakerTitle = true
  286.                         system.savePlayerData(n,serialization(info[n].db))
  287.                         tfm.exec.chatMessage("<CE>[•] "..system.communityTranslation.credits,n)
  288.                         info[n].mapDone = true
  289.                     else
  290.                         if not info[n].mapDone then
  291.                             tfm.exec.chatMessage("<R>:(",n)
  292.                         end
  293.                     end
  294.                 end
  295.             end
  296.         else
  297.             if not info[n].mapDone then
  298.                 tfm.exec.chatMessage("<R>"..system.communityTranslation.nochances.." :(",n)
  299.             end
  300.         end
  301.     end
  302. end
  303. for i = 0,50 do
  304.     system.disableChatCommandDisplay(tostring(i),true)
  305. end
  306. for k,v in next,system.communityTranslation.grounds do
  307.     system.disableChatCommandDisplay(v[1],true)
  308.     system.disableChatCommandDisplay(v[1]:lower(),true)
  309.     system.disableChatCommandDisplay(v[1]:upper(),true)
  310. end
  311.  
  312. --[[ Map ]]--
  313. table.random=function(t)
  314.     return (type(t)=="table" and t[math.random(#t)] or math.random())
  315. end
  316. tfm.exec.newGame("#"..table.random({7,17}))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement