How to get index in an array list?

Asked

Viewed 50 times

-3

I need to check if there is an element with the nome as FH02, because I can’t use it because I don’t know where you stand.

Config = {}
Config.Homes = {
{['nome'] = "FH02", ['qtde'] = 2, ['valor'] = 1000000 , ['bau'] = 1000, ['entrada'] = {-884.29,517.72,92.44},['saida'] = {-894.57,491.41,76.14},['bauloc'] = {-878.30,500.87,75.64} },
    {['nome'] = "FH03", ['qtde'] = 2, ['valor'] = 1000000 , ['bau'] = 1000, ['entrada'] = {-842.84,466.65,87.59},['saida'] = {-828.34,463.77,79.49},['bauloc'] = {-811.00,471.09,78.99} },
    {['nome'] = "FH04", ['qtde'] = 2, ['valor'] = 1000000 , ['bau'] = 1000, ['entrada'] = {-848.68,508.62,90.81},['saida'] = {-848.24,519.68,82.76},['bauloc'] = {-838.68,503.47,82.27} },
    {['nome'] = "FH05", ['qtde'] = 2, ['valor'] = 1000000 , ['bau'] = 1000, ['entrada'] = {-873.57,562.67,96.61},['saida'] = {-856.53,566.61,83.67},['bauloc'] = {-871.83,577.57,83.18} },
    {['nome'] = "FH06", ['qtde'] = 2, ['valor'] = 1000000 , ['bau'] = 1000, ['entrada'] = {-904.55,588.12,101.19},['saida'] = {-884.54,603.7,87.58},['bauloc'] = {-902.02,608.3,86.98} },
}
-- Não posso fazer isso porque não sei qual é sua posição.
if (Config.Homes[1]['nome'] == "FH02") then
    print('true')
else
    print('false')
end

1 answer

0

I’m not sure if this solution works with normal Lua, but I’m pretty sure it works with rbx. Lua:

for i,v in pairs(Config.Homes) do
if i == 'nome' and v == "FH02" then
print("true")
else
print("false")
end
end

Browser other questions tagged

You are not signed in. Login or sign up in order to post.