nociam 90 Postado Agosto 14, 2016 Share Postado Agosto 14, 2016 Bom Acho que to com a logica fraca xd, como faço pegar uma tabela por nome digo quero um Randon do Pedro e do João, se eu fazer por numero esta indo mas queria pelo nomes? local pokemons = { ["pedro"] = { {name = "Mega Blastoise", level = 600, nick = "", ball = "normal"}, {name = "Mega Scizor", level = 600, nick = "", ball = "normal"}, {name = "Shiny Snorlax", level = 600, nick = "", ball = "normal"}, {name = "Mega Charizard Y", level = 600, nick = "", ball = "normal"}, {name = "Shiny Dragonite", level = 600, nick = "", ball = "normal"}, {name = "Mewtwo", level = 600, nick = "", ball = "normal"}, } ["joao"] = { {name = "Mega Blastoise", level = 600, nick = "", ball = "normal"}, {name = "Mega Scizor", level = 600, nick = "", ball = "normal"}, {name = "Shiny Snorlax", level = 600, nick = "", ball = "normal"}, {name = "Mega Charizard Y", level = 600, nick = "", ball = "normal"}, {name = "Shiny Dragonite", level = 600, nick = "", ball = "normal"}, {name = "Mewtwo", level = 600, nick = "", ball = "normal"}, } } local names = getCreatureName(cid) local it = pokemons[names][battle_turn] Link para o comentário Compartilhar em outros sites More sharing options...
1 zipter98 1101 Postado Agosto 14, 2016 Share Postado Agosto 14, 2016 (editado) local pokemons = { ["pedro"] = { {name = "Mega Blastoise", level = 600, nick = "", ball = "normal"}, {name = "Mega Scizor", level = 600, nick = "", ball = "normal"}, {name = "Shiny Snorlax", level = 600, nick = "", ball = "normal"}, {name = "Mega Charizard Y", level = 600, nick = "", ball = "normal"}, {name = "Shiny Dragonite", level = 600, nick = "", ball = "normal"}, {name = "Mewtwo", level = 600, nick = "", ball = "normal"}, }, ["joao"] = { {name = "Mega Blastoise", level = 600, nick = "", ball = "normal"}, {name = "Mega Scizor", level = 600, nick = "", ball = "normal"}, {name = "Shiny Snorlax", level = 600, nick = "", ball = "normal"}, {name = "Mega Charizard Y", level = 600, nick = "", ball = "normal"}, {name = "Shiny Dragonite", level = 600, nick = "", ball = "normal"}, {name = "Mewtwo", level = 600, nick = "", ball = "normal"}, }}local index = {}for name, _ in pairs(pokemons) do table.insert(index, name)endlocal it = pokemons[index[math.random(1, #index)]][battle_turn] Editado Agosto 14, 2016 por zipter98 Link para o comentário Compartilhar em outros sites More sharing options...
0 nociam 90 Postado Agosto 15, 2016 Autor Share Postado Agosto 15, 2016 solucionado obrigado. Link para o comentário Compartilhar em outros sites More sharing options...
Pergunta
nociam 90
Bom Acho que to com a logica fraca xd, como faço pegar uma tabela por nome digo quero um Randon do Pedro e do João, se eu fazer por numero esta indo mas queria pelo nomes?
["pedro"] = {
{name = "Mega Blastoise", level = 600, nick = "", ball = "normal"},
{name = "Mega Scizor", level = 600, nick = "", ball = "normal"},
{name = "Shiny Snorlax", level = 600, nick = "", ball = "normal"},
{name = "Mega Charizard Y", level = 600, nick = "", ball = "normal"},
{name = "Shiny Dragonite", level = 600, nick = "", ball = "normal"},
{name = "Mewtwo", level = 600, nick = "", ball = "normal"},
}
["joao"] = {
{name = "Mega Blastoise", level = 600, nick = "", ball = "normal"},
{name = "Mega Scizor", level = 600, nick = "", ball = "normal"},
{name = "Shiny Snorlax", level = 600, nick = "", ball = "normal"},
{name = "Mega Charizard Y", level = 600, nick = "", ball = "normal"},
{name = "Shiny Dragonite", level = 600, nick = "", ball = "normal"},
{name = "Mewtwo", level = 600, nick = "", ball = "normal"},
}
}
local it = pokemons[names][battle_turn]
Link para o comentário
Compartilhar em outros sites
2 respostass a esta questão
Posts Recomendados