Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- OldSurvivor #2
- --[[ ID list
- textArea
- 1 debug(?) classic
- 10 notifications - cerrar (hardmode, achievements)
- 11 perfil - ventana principal
- 12 perfil - cerrar
- 21+ perfil - pestañas
- popUp
- ]]
- do
- function flattenFunctionTree(tree, path)
- for name, value in pairs(tree) do
- if type(value) == "table" then
- flattenFunctionTree(value, path .. name .. "_")
- elseif type(value) == "function" then
- _G[path .. name] = value
- end
- end
- end
- local temp = {}
- for name, value in pairs(_G) do
- if value ~= _G then
- temp[name] = value
- end
- end
- flattenFunctionTree(temp, "")
- end
- local game_name = "new old new old new survivor"
- local game_owner = "Musugas"
- local game_id = 101
- local game_data_version = 3
- local data_header = "PATO0003"
- local stats_name = {"level","exp","money","a_shop"}
- local stats_size = {1,3,3,1}
- local stats_n = 4
- local playerData = {}
- local playerFile = {}
- -- settings
- local s_min_players = 3
- local s_max_level = 100
- local imgs = {
- logo = "";
- logros = {},
- win ="",
- no_shamanModes="",
- windows = {"","",""}, -- Shop, Ranking, Logros
- profile = {} -- Random imgs
- }
- local _unlock = {
- {1,3,5,10,20,40},
- {1,2},
- {1,2},
- {1},
- {1},
- {1},
- {1}
- }
- local text = {
- es = {
- logros = {
- {"Ratón Clásico","a2","a3","a4","a5","a6"},
- {"En equipos","Patata"},
- {"Granja de ovejas","Ponquesito"},
- {"Chamán unitario"},
- {"Conde Drekkemaus"},
- {"Caza fantasmas"},
- {"Cursor"}
- },
- welcome = "Bienvenido a #OldSurvivor. Estamos en fase de pruebas, todo lo hecho, será borrado despues.",
- ach_unlocked = "Nuevo logro desbloqueado",
- hm_header = "Desactiva Hard Mode o Divine Mode para jugar",
- hm_text = "Al hacerlo, reaparecerás",
- lvl_up = "%s <BL>ha subido al nivel %d",
- team_win = "El equipo %s ha ganado",
- shaman_win = "¡El chamán ha ganado!",
- mice_win = "¡Los ratones han ganado!",
- no_win = "Nadie ganó :[",
- countdown = "<BL>El chamán tiene 20 segundos para matar a %s",
- is_shaman = "%s <BL>es ahora el chamán ¡Cuidado!",
- is_vampire = "%s es ahora Drekkemaus",
- blue = "Azul",
- red = "Rojo",
- win = "%s ha ganado",
- vampire_win = "Los sirvientes del conde Drekkemaus, han ganado",
- introduction = {
- [0] = "Se necesitan 3 ratones para jugar",
- "Sobrevive al ataque del todopoderoso chamán",
- "¡Derrota al otro equipo!",
- "Abre el paraguas, y cubrete de la lluvia de objetos",
- "Derrota a los demás chamanes",
- "Muerde a los demás",
- "¡BUU! Cuidado con los fantasmas",
- "El mundo informatico le dió el poder del Mouse a un raton"
- }
- },
- en = {
- logros = {
- {"Ratón Clásico","a2","a3","a4","a5","a6"},
- {"En equipos","Patata"},
- {"Granja de ovejas","Ponquesito"},
- {"Chamán unitario"},
- {"Conde Drekkemaus"},
- {"Caza fantasmas"},
- {"Cursor"}
- },
- welcome = "Welcome to #OldSurvivor. We are in testings, everything done, will be deleted later.",
- ach_unlocked = "New achievement unlocked",
- hm_header = "Disable Hard Mode or Divine Mode to play",
- hm_text = "Once disabled, you'll reappear",
- lvl_up = "%s is now level %d",
- team_win = "%s team has won",
- shaman_win = "The Shaman has won!",
- mice_win = "The mice have won!",
- no_win = "No contest :[",
- countdown = "The Shaman's got 20 seconds to kill %s",
- is_shaman = "%s is now the Shaman. Watch out!",
- is_vampire = "%s is now Drekkemaus",
- blue = "Blue",
- red = "Red",
- win = "%s has won",
- vampire_win = "Count Drekkemaus' servants have won",
- introduction = {
- [0] = "3 mice are needed in order to play",
- "Survive the attack of the almighty Shaman",
- "Defeat the other team!",
- "Open the umbrella, and cover yourself from the rain of objects",
- "Defeat the other shamans",
- "Bite the other mice",
- "BOO! Watch out for the ghosts",
- "Computer science gave a mouse the power of the Click"
- }
- }
- }
- -- const
- local LOBBY,CLASSIC,TEAMS,RAIN,ALLSHAMANS,VAMPIRE,GHOST,CLICK = 0,1,2,3,4,5,6,7
- -- datos
- --local maps = {5356733,4752763,5315470,5346896,4858080,4690132,4975835,5355152,5356589,5356805,5356815,5358594,5382526,5383222,5383462,5315218,4667683,5383505,4666824,4666393,4494912,4479901,4478049,4446077,4386714,4372471,4671796,5393225,5393409,5393149,5393484,5393151,5397551,5402869,5399385,5402898,5399265,5416277,5412457,5420479,5420408,5432422,5432381,5432347,5435548,5428059,5427979,5425838,5425724,5422451,5422637,5422414,5420632,5421011,5420537}
- local maps = {5355152,5445280,5346896,5393409,5445181,5445572,5445400}
- local lobby = {5468613,5468613}
- --local maps = {5355152,5355152} --CLASSIC
- --local maps = {5445280,5445280} --TEAMS
- --local maps = {5346896,5346896} --RAIN
- --local maps = {5393409,5393409} --AllSHAMANS
- --local maps = {5445181,5445181} --VAMPIRE
- --local maps = 55445262,5445262} --GHOST
- --local maps = {5445572,5445572} -- Ghost ~viprin
- --local maps = {5445400,5445400} -- Clicker
- local keys = {37,64,81,39,68,32,40,83}
- local _modos = {
- {"Lobby",30,0,0},
- {"Classic",120,30,10},
- {"Teams",130,30,10},
- {"Rain",60,25,10},
- {"Allshamans",130,35,20},
- {"Vampire",120,35,20},
- {"Ghost",60,25,10},
- {"Click",130,30,20},
- }
- local modos = {}
- for i=1,8 do modos[i-1] = {name = _modos[i][1], time = _modos[i][2], exp = math_floor(_modos[i][3]/5), money = math.floor(_modos[i][4]/5)} end
- -- variables del juego
- local playersInRoom = 0
- local playersAlive = 99
- local shaman
- local vampire = {}
- local miceAlive = {}
- local currentMap
- local gameMode
- local gameLoaded
- local gameStarted
- local gameFinished
- local blue = {}
- local red = {}
- local startMode = false
- local xmldom
- local data = {}
- local imageBox_id = {}
- local inEasyMode = {}
- local mice_afk = {}
- local killed_afk
- -- variables específicas de minijuegos
- -- classic
- local classic_countdown
- local classic_winner
- local classic_rival
- -- teams
- local teams_red = {}
- local teams_blue = {}
- local teams_blue_n = 0
- local teams_red_n = 0
- -- rain
- local rain_winner
- -- allshamans
- local allshamans_winner
- -- vampire
- local vampire_winner
- local vampire_normalMice
- -- ghost
- local ghost_winner
- -- click
- local click_countdown
- local click_winner
- local click_rival
- function loadGame()
- tfm.exec.disableAutoNewGame(true)
- tfm.exec.disableAutoTimeLeft(true)
- tfm.exec.disableAllShamanSkills(true)
- tfm.exec.disableAutoShaman (true)
- tfm.exec.disableAutoTimeLeft (true)
- math_randomseed(os.time())
- for _,com in ipairs({"comando","comandu"}) do
- system_disableChatCommandDisplay(com, true)
- end
- for name in pairs(tfm.get.room.playerList) do
- eventNewPlayer(name)
- end
- startGame()
- end
- function eventNewPlayer(name)
- data[name] = {
- name = name,
- timestamp = 0,
- facing = true,
- win_profile = false,
- profileUser = nil,
- profileTab = 1
- }
- playersInRoom = playersInRoom + 1
- for _,k in pairs(keys) do
- tfm_exec_bindKeyboard(name, k, true)
- end
- playerData[name] = defaultData()
- if gameLoaded and playersInRoom == s_min_players then
- modeEnd()
- end
- outputMsg("<ROSE><b>"..getTrans().welcome.."</b>",name)
- end
- function outputMsg(txt,to)
- ui.addTextArea(600,txt.."<a href='event:petra'><R> [X]",to,400, 25,nil,nil,0x26353d,0x435e6c,0.8,true)
- end
- function eventPlayerLeft(name)
- playersInRoom = playersInRoom - 1
- data[name] = nil
- end
- function eventPlayerDied(name)
- if gameFinished or not gameLoaded then return end
- miceAlive[name] = nil
- playersAlive = playersAlive - 1
- checkPlayers()
- if gameMode == CLASSIC then
- if classic_countdown then
- if name == shaman then
- classic_winner = 2
- else
- classic_winner = 1
- end
- modeEnd()
- else
- if name==shaman then
- classic_winner = 2
- modeEnd()
- else
- if playersAlive == 2 and classic_winner == 0 then
- tfm_exec_setGameTime(20)
- classic_countdown = true
- for m in pairs(miceAlive) do
- if m ~= shaman then
- classic_rival = m
- break
- end
- end
- --debugMsg(shaman.." tiene 20 segundos para matar a "..classic_rival)
- outputMsg("<J>"..string_format(getTrans().countdown,"<CH>"..classic_rival),name)
- end
- end
- end
- elseif gameMode == GHOST then
- if playersAlive == 1 then
- for m in pairs(miceAlive) do
- ghost_winner = m
- end
- modeEnd()
- end
- elseif gameMode == CLICK then
- if click_countdown then
- if name == shaman then
- click_winner = 2
- else
- click_winner = 1
- end
- modeEnd()
- else
- if name==shaman then
- click_winner = 2
- modeEnd()
- else
- if playersAlive == 2 and click_winner == 0 then
- tfm_exec_setGameTime(20)
- click_countdown = true
- for m in pairs(miceAlive) do
- if m ~= shaman then
- click_rival = m
- break
- end
- end
- outputMsg("<BL>"..string_format(getTrans().countdown,"<J>"..click_rival),name)
- end
- end
- end
- end
- end
- function checkPlayers()
- if playersAlive == 0 or playersAlive == 1 and not gameFinished then
- modeEnd()
- end
- end
- function eventPlayerVampire(name)
- if gameFinished then return end
- vampire[name] = true
- miceAlive[name] = nil
- vampire_normalMice = vampire_normalMice - 1
- if vampire_normalMice == 0 then
- modeEnd()
- end
- end
- function startGame()
- local players_easy = 0
- inEasyMode = {}
- for name in pairs(data) do
- if tfm.get.room.playerList[name] and tfm.get.room.playerList[name].inHardMode == 0 then
- players_easy = players_easy + 1
- end
- end
- local mapList
- if players_easy >= s_min_players then
- mapList = maps
- else
- mapList = lobby
- end
- local newMap
- repeat
- newMap = math_random(#mapList)
- until newMap ~= currentMap or #mapList == 1
- currentMap = newMap
- tfm_exec_newGame(mapList[newMap])
- end
- function checkShamanMode(name)
- if tfm.get.room.playerList[name].inHardMode == 0 then
- --ui_removeTextArea(10, name)
- else
- sendNotification(name, getTrans().hm_header, getTrans().hm_text,"HTX7faD")
- tfm_exec_killPlayer(name)
- end
- end
- function eventNewGame()
- gameLoaded = true
- gameStarted = false
- gameFinished = false
- killed_afk = false
- local xml = tfm.get.room.xmlMapInfo.xml
- xmldom = parseXml(xml)
- gameMode = path(xmldom, "P")[1].attribute.olds or 0
- gameMode = gameMode + 0
- tfm_exec_setGameTime(modos[gameMode].time + 8)
- outputMsg("<font color='#29c4d9'><b>~ "..modos[gameMode].name.."</b><N> "..getTrans().introduction[gameMode],nil)
- playersAlive = playersInRoom
- miceAlive = {}
- mice_afk = {}
- for name in pairs(data) do
- miceAlive[name] = true
- mice_afk[name] = true
- if gameMode ~= 0 then
- sumarStat(name, "rounds", gameMode)
- tfm_exec_setNameColor(name,"0")
- end
- end
- if gameMode == CLASSIC then
- classic_countdown = false
- classic_winner = 0
- classic_rival = ""
- elseif gameMode == TEAMS then
- teams_red = {}
- teams_blue = {}
- teams_red_n = 0
- teams_blue_n = 0
- make_teams()
- elseif gameMode == RAIN then
- rain_winner = nil
- elseif gameMode == ALLSHAMANS then
- shaman = "All"
- allshamans_winner = nil
- elseif gameMode == VAMPIRE then
- vampire_winner = nil
- vampire_normalMice = playersAlive
- vampire = {}
- elseif gameMode == GHOST then
- ghost_winner = nil
- elseif gameMode == CLICK then
- click_countdown = false
- click_winner = 0
- click_rival = ""
- end
- end
- function modeLoop(time,tr)
- if gameMode == RAIN then
- local objects={5,2,6,3,10,17,23,39,40,17}
- for i=1,4 do
- tfm_exec_addShamanObject(objects[math_random(10)],math_random(800), math_random(-400,-100),0,0,math_random(10,30))
- end
- elseif gameMode == GHOST then
- local x,y
- for i=1,7 do
- x = math_random(0,800)
- y = math_random(0,400)
- tfm_exec_explosion(x, y, 60, 80, false)
- tfm_exec_displayParticle(3,x, y,3,-9,0,1,nil)
- end
- end
- end
- function getShaman()
- local tchaman = {}
- for name, player in pairs(tfm.get.room.playerList) do
- if not player.isDead then
- table_insert (tchaman, {name=name, score=player.score})
- end
- end
- table_sort(tchaman, function (x,y) return x.score > y.score end)
- return tchaman[1].name
- end
- function getVampire()
- local t = {}
- local c = 0
- for name in pairs(miceAlive) do
- c = c + 1
- t[c] = name
- end
- return t[math_random(c)]
- end
- function make_teams()
- local playerList = {}
- local c = 0
- for n in pairs(data) do
- c = c + 1
- playerList[c] = n
- end
- local DS = path(xmldom, "Z","D","DS")[1].attribute
- local DC = path(xmldom, "Z","D","DC")[1].attribute
- local red_x,red_y,blue_x,blue_y = DS.X,DS.Y,DC.X,DC.Y
- for i=1,c do
- local index = math_random(c)
- local player = playerList[index]
- if i%2==0 then
- teams_red[player] = true
- teams_red_n = teams_red_n + 1
- tfm_exec_setNameColor(player,"0xEB1D51")
- tfm_exec_movePlayer(player, red_x, red_y)
- else
- teams_blue[player] = true
- teams_blue_n = teams_blue_n + 1
- tfm_exec_setNameColor(player,"0x2F7FCC")
- tfm_exec_movePlayer(player, blue_x, blue_y)
- end
- table_remove(playerList, index)
- c = c - 1
- end
- end
- function modeStart()
- outputMsg("<J>¡GO!")
- for name in pairs(miceAlive) do
- checkShamanMode(name)
- end
- if gameMode == CLASSIC then
- shaman = getShaman()
- tfm_exec_setShaman(shaman)
- outputMsg(string_format(getTrans().is_shaman,"<CH>"..shaman),nil)
- elseif gameMode == ALLSHAMANS then
- for p in pairs(data) do
- tfm_exec_setShaman(p)
- end
- elseif gameMode == VAMPIRE then
- local name = getVampire()
- tfm_exec_setVampirePlayer(name)
- outputMsg(string_format(getTrans().is_vampire,"<CH>"..name),nil)
- elseif gameMode == CLICK then
- shaman = getShaman()
- getClicker(shaman)
- tfm_exec_setPlayerScore(shaman, 0)
- outputMsg(string_format(getTrans().is_shaman,"<CH>"..shaman),nil)
- end
- end
- function getClicker(name)
- system.bindMouse(name,true)
- local DC = path(xmldom, "Z","D","DC")[1].attribute
- local x,y= DC.X,DC.Y
- tfm_exec_setNameColor(name,"0xEB1D51")
- tfm_exec_movePlayer(name, x, y)
- end
- function sendNotification(name,header,text,img)
- ui_addTextArea(10, "<p align='center'><font size='20'><J>"..header.."\n<font size='10'><BL>"..text.."\n\n<R>[<a href='event:close'>CLOSE</a>]", name,250,185,300,95,0x26353d,0x435e6c,nil,true)
- --imageBox_id[name] = tfm_exec_addImage(img..".png","!1", 320, 85,name)
- end
- function sumarStat(name, s, g)
- local p = playerData[name]
- p[s][g] = p[s][g] + 1
- if s == "rounds" then
- checkAch(name)
- elseif not mice_afk[name] then
- local modo = modos[g]
- getExp(name, modo.exp * p.level * 5)
- getMoney(name, modo.money * 5)
- end
- end
- function getMoney(name, money)
- local p = playerData[name]
- p.money = p.money + money
- --debugMsg("<CH>"..name.." has obtenido $"..money.." Musudólares. Dinero total: "..p.money,name)
- end
- function getExp(name, earned, money)
- local p,trans = playerData[name],getTrans()
- p.exp = p.exp + earned
- local level = p.level
- local exp_req = level*level*25
- if p.level < s_max_level and p.exp >= exp_req then
- level = level + 1
- p.level = level
- p.exp = p.exp - exp_req
- --debugMsg(name.." ha subido al nivel "..level+1)
- outputMsg("<BL>"..string_format(trans.lvl_up,"<J>"..name,level+1), nil)
- end
- --debugMsg(name.." ha obtenido "..earned.." puntos de experiencia.\nExperiencia total: "..p.exp..".\nSiguiente nivel:"..level*level*25 - p.exp,name)
- end
- function modeEnd()
- tfm_exec_setGameTime(5)
- gameFinished = true
- local T = getTrans()
- if gameMode == CLASSIC then
- ui_removeTextArea(1,nil)
- if classic_winner == 1 then
- -- todos muertos menos el chami
- outputMsg("<J>"..T.shaman_win,nil)
- sumarStat(shaman,"wins", 1)
- else
- if classic_countdown then
- -- chamán muerto o tiempo, gana el rival
- --debugMsg(classic_rival.." ha ganado!")
- outputMsg("<BL>"..string_format(T.win,"<J>"..classic_rival.."<BL>"),nil)
- sumarStat(classic_rival, "wins", 1)
- else
- -- chamán muerto o tiempo, los ratones sobrevivientes ganan
- -- debugMsg("¡Los ratones han ganado!")
- outputMsg(T.mice_win,nil)
- for name in pairs(miceAlive) do
- if name~=shaman then
- sumarStat(name, "wins", 1)
- end
- end
- end
- end
- elseif gameMode == TEAMS then
- if teams_blue_n == 0 then
- -- rojo gana
- --debugMsg("El <R>equipo rojo <VP>ha ganado")
- outputMsg("<J>"..string_format(T.team_win,'<R>'..T.red.."<J>"),nil)
- for name in pairs(teams_red) do
- sumarStat(name, "wins", 2)
- end
- elseif teams_red_n == 0 then
- -- azul gana
- -- debugMsg("El <BV>equipo azul <VP>ha ganado")
- outputMsg("<J>"..string_format(T.team_win,'<BV>'..T.blue..'<J>'),nil)
- for name in pairs(teams_blue) do
- sumarStat(name, "wins", 2)
- end
- else
- -- tiempo, ninguno gana
- --debugMsg("Ningún equipo ha ganado")
- outputMsg('<J>'..T.no_win,nil)
- end
- elseif gameMode == RAIN then
- if rain_winner then
- --debugMsg(rain_winner.." ganó")
- outputMsg(string_format(T.win,"<J>"..rain_winner.."<BL>"),nil)
- sumarStat(rain_winner, "wins", 3)
- else
- --debugMsg("Nadie ganó :(")
- outputMsg('<J>'..T.no_win,nil)
- end
- elseif gameMode == ALLSHAMANS then
- if allshamans_winner then
- -- debugMsg(allshamans_winner.." ganó")
- outputMsg(string_format(T.win,"<J>"..allshamans_winner.."<BL>"),nil)
- sumarStat(allshamans_winner,"wins", 4)
- else
- -- debugMsg("Nadie ganó :(")
- outputMsg('<J>'..T.no_win,nil)
- end
- elseif gameMode == VAMPIRE then
- for name in pairs(vampire) do
- tfm_exec_killPlayer(name)
- end
- if vampire_normalMice == 0 then
- -- todos convertidos en vampiros o muertos
- --debugMsg("El conde Drekkemaus ha ganado")
- outputMsg("<J>"..T.vampire_win,nil)
- elseif vampire_normalMice == 1 then
- -- se acabó el tiempo y 1 jugador sobreviviente
- for name in pairs(miceAlive) do
- if not vampire[name] then
- sumarStat(name, "wins", 5)
- outputMsg(string_format(T.win,"<J>"..name.."<BL>"),nil)
- break
- end
- end
- elseif vampire_normalMice > 1 then
- -- se acabó el tiempo y más de 1 jugador sobreviviente
- --debugMsg("¡Los ratones han ganado!")
- outputMsg("<J>"..T.mice_win,nil)
- --local temp = ""
- for name in pairs(miceAlive) do
- --temp = temp..name.." "
- sumarStat(name,"wins", 5)
- end
- --debugMsg("Ganadores: "..temp)
- end
- elseif gameMode == GHOST then
- if ghost_winner then
- --debugMsg(ghost_winner.." ganó")
- outputMsg(string_format(T.win,"<J>"..ghost_winner.."<BL>"),nil)
- sumarStat(ghost_winner,"wins", 6)
- else
- outputMsg('<J>'..T.no_win,nil)
- end
- elseif gameMode == CLICK then
- ui_removeTextArea(1,nil)
- system.bindMouse(shaman, false)
- if click_winner == 1 then
- -- todos muertos menos el chami
- --debugMsg("El chamán ganó")
- outputMsg('<J>'..T.shaman_win,nil)
- sumarStat(shaman,"wins", 7)
- else
- if click_countdown then
- -- chamán muerto o tiempo, gana el rival
- -- debugMsg(click_rival.." ha ganado!")
- outputMsg(string_format(T.win,"<J>"..click_rival.."<BL>"),nil)
- sumarStat(click_rival,"wins", 7)
- else
- -- chamán muerto o tiempo, los ratones sobrevivientes ganan
- --debugMsg("¡Los ratones han ganado!")
- outputMsg('<J>'..T.mice_win,nil)
- -- local temp = ""
- for name in pairs(miceAlive) do
- if name~=shaman then
- -- temp = temp..name.." "
- sumarStat(name,"wins", 7)
- end
- end
- --debugMsg("Ganadores: "..temp)
- end
- end
- end
- if gameMode ~= LOBBY then
- for name in pairs(data) do
- if not mice_afk[name] then
- local modo = modos[gameMode]
- getExp(name, modo.exp * playerData[name].level)
- getMoney(name, modo.money)
- end
- if miceAlive[name] then
- tfm_exec_killPlayer(name)
- end
- end
- end
- end
- function eventLoop(time,tr)
- if not gameLoaded then return end
- if not gameStarted then
- if time > 8000 then
- gameStarted = true
- modeStart()
- end
- return
- end
- if not killed_afk and time >= 30000 then
- for n in pairs(mice_afk) do
- tfm_exec_killPlayer(n)
- killed_afk = true
- --debugMsg(n.." está en modo AFK")
- end
- end
- modeLoop(time,tr)
- if not gameFinished and tr <= 0 then
- modeEnd()
- elseif gameFinished and tr <=0 then
- startGame()
- end
- end
- function eventKeyboard(name, key, down, x, y)
- if key == 23492 then
- -- ayuda
- elseif miceAlive[name] then
- if mice_afk[name] then mice_afk[name] = nil end
- if gameMode == CLICK or gameMode == TEAMS and not gameFinished then
- if key == 37 or key == 64 or key == 81 then
- data[name].facing=false
- return
- elseif key == 39 or key == 68 then
- data[name].facing=true
- return
- end
- if gameMode == TEAMS and gameStarted then
- if (key == 32 or key == 40 or key == 83) then
- if data[name].timestamp < os.time() - 1500 then
- local id
- if data[name].facing then
- id = tfm_exec_addShamanObject(17,x+10,y-15,90)
- else
- id = tfm_exec_addShamanObject(17,x-10,y+15,-90)
- end
- data[name].timestamp = os.time()
- end
- end
- end
- end
- end
- end
- function eventMouse(name, mx, my)
- if gameMode == CLICK and name == shaman then
- if mice_afk[name] then mice_afk[name] = nil end
- if data[name].timestamp < os.time() - 1500 then
- local id
- if data[name].facing then
- id = tfm_exec_addShamanObject(17,mx,my,90)
- else
- id = tfm_exec_addShamanObject(17,mx,my,-90)
- end
- data[name].timestamp = os.time()
- end
- end
- end
- function eventChatCommand(name, com)
- if com:sub(1,7) == "profile" then
- local n = com:sub(9)
- n = data[n] and n or name
- showProfile(name, n)
- elseif com:sub(1,5) == "stats" then
- local n = com:sub(7)
- n = data[n] and n or name
- local t,p = n.."\n",playerData[n]
- local r,w = p.rounds,p.wins
- for i = 1,7 do
- t=t..modos[i].name.." - rounds: "..r[i].." wins: "..w[i].."\n"
- end
- debugMsg(t)
- elseif com:sub(1,6) == "logros" then
- local n = com:sub(8)
- n = data[n] and n or name
- local t,p = "Logros de "..n.."\n",playerData[n]
- local l = p.logros
- for i = 1,7 do
- li = l[i]
- t=t..modos[i].name.." - logros ("..li.."): "
- for j = 1,li do
- t=t..getTrans().logros[i][j]..", "
- end
- t=t.."\n"
- end
- debugMsg("<BL>"..t.."</BL>")
- end
- end
- function eventTextAreaCallback(id, name, cb)
- if id == 10 then
- ui_removeTextArea(10,name)
- if imageBox_id[name] then
- tfm_exec_removeImage(imageBox_id[name],name)
- end
- elseif id == 12 then
- local m = data[name]
- if m.win_profile then
- m.win_profile = false
- for i=1,22 do
- ui_removeTextArea(i, name)
- end
- end
- elseif cb:find("changeProfileTab") then
- if cb:sub(17) then
- id = cb:sub(17)
- end
- data[name].profileTab = id - 20
- updateProfile(name, data[name].profileUser)
- end
- end
- -- name: nombre del usuario cuyo perfil se muestra
- -- target: nombre del usuario al que se le mostrará la ventana
- function showProfile(target, name)
- local T = getTrans()
- local m = data[target]
- local p = playerData[name]
- m.win_profile = true
- m.profileUser = name
- m.profileTab = 1
- ui_addTextArea(11,"",target,230,110,300,270,0x26353d,0x26353d,nil,true);
- ui_addTextArea(13,"<p align='center'><font size='20' face='Arial Black'><CH>"..name,target,210,60,350,40,0x3a4e61,0x26353d,nil,true)
- ui_addTextArea(22,"<p align='center'><N><a href='event:changeProfileTab'><b>Achiev</b></a></p>",target,230,70,nil,16,0x26353d,0x26353d,nil,true)
- --ui_addTextArea(23,"<p align='center'><N><a href='event:changeProfileTab'><b>Modes</b></a></p>",p,550,160,nil,16,0x26353d,0x26353d,nil,true)
- ui_addTextArea(12, "<p align='center'><R><a href='event:close'><b>☓</b></p>",target,530,70,nil,16,0x26353d,0x26353d,nil,true)
- updateProfile(target, name)
- end
- function updateProfile(target, name)
- local T = getTrans()
- local m = data[target]
- local p = playerData[name]
- local txt,data,id = "Main page"
- if m.profileTab == 2 then
- data,id = achievements(name,1,20), 21
- elseif m.profileTab == 3 then
- data,id = "Modos", 21
- else
- local r,w,wins,rounds= p.rounds,p.wins,0,0
- for i = 1,7 do
- wins= wins + w[i]
- rounds = rounds + r[i]
- end
- mort = rounds - wins
- data = string.format("<p align='center'></p><font size='13'><N>• Nivel:<J> %d</font><G> <BL><font size='13'><N>\n<BL>• Leaderboard: <J>%s <BL>[%s]</font></BL>\n\n<N>Estadísticas generales\n<BL>• Triunfos: <J>%d<BL>\n• Derrotas: <J>%d\n\n",p.level,"No ranking","No ranking",wins,mort)
- txt = "Achiev"
- id = 22
- end
- ui_updateTextArea(22,"<p align='center'><N><a href='event:changeProfileTab"..id.."'><b>"..txt.."</b></a></p>",target)
- ui_updateTextArea(11,data,target)
- end
- function checkAch(name)
- local g,logros = gameMode,playerData[name].logros
- for i=logros[g]+1,#_unlock[g] do
- if playerData[name].rounds[g] >= _unlock[g][i] then
- logros[g] = logros[g] + 1
- sendNotification(name, getTrans().logros[g][logros[g]], getTrans().ach_unlocked, "HTX7faD")
- end
- end
- end
- function achievements(name,n1,n2)
- local t,logros,achText = "",playerData[name].logros,getTrans().logros
- for i=1,7 do
- for a=n1,n2 do
- if logros[i] >= a then
- t = t..achText[i][a].." \n"
- end
- end
- end
- return t
- end
- function defaultData()
- local d = {
- level = 100,
- exp = 0,
- money = 0,
- a_shop = 1,
- logros = {},
- rounds = {},
- wins = {},
- shop = {}
- }
- for i=1,7 do
- d.logros[i] = 0
- d.rounds[i] = 0
- d.wins[i] = 0
- end
- d.shop[0] = true
- for i=1,42 do
- d.shop[i] = false
- end
- return d
- end
- local statGroup = {"rounds","wins","logros"}
- local statGroup_size = {3,3,1}
- function string_replace(s, i, j, t)
- return s:sub(1,i-1)..t..s:sub(j+1)
- end
- function getTrans()
- return text[tfm_get_room_community] or text['es']
- end
- function debugMsg(msg,target)
- outputMsg("<VP>"..msg, target)
- if target then
- sendNotification(name,msg,"","HTX7faD")
- end
- end
- -- Makinit's xml library
- do
- local namePattern = "[%a_:][%w%.%-_:]*"
- function parseXml(xml)
- local root = {}
- local parents = {}
- local element = root
- for closing, name, attributes, empty, text in string_gmatch(xml, "<(/?)(" .. namePattern .. ")(.-)(/?)>%s*([^<]*)%s*") do
- if closing == "/" then
- local parent = parents[element]
- if parent and name == element.name then
- element = parent
- end
- else
- if name ~= "L" then
- local child = {name = name, attribute = {}}
- table_insert(element, child)
- parents[child] = element
- if empty ~= "/" then
- element = child
- end
- for name, value in string_gmatch(attributes, "(" .. namePattern .. ")%s*=%s*\"(.-)\"") do
- child.attribute[name] = value
- end
- end
- end
- if text ~= "" then
- local child = {text = text}
- table_insert(element, child)
- parents[child] = element
- end
- end
- return root[1]
- end
- function path(nodes, ...)
- nodes = {nodes}
- for i, name in ipairs(arg) do
- local match = {}
- for i, node in ipairs(nodes) do
- for i, child in ipairs(node) do
- if child.name == name then
- table_insert(match, child)
- end
- end
- end
- nodes = match
- end
- return nodes
- end
- end
- loadGame()
- -- MUSUGAS AND HINAKAGIYAMA
Advertisement
Add Comment
Please, Sign In to add comment