Ir para conteúdo
  • 0

nociam

Pergunta

 

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

2 respostass a esta questão

Posts Recomendados

  • 1
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 por zipter98
Link para o comentário
Compartilhar em outros sites

×
×
  • Criar Novo...