3
I need to use a table in Lua, but I can only reference it through a string, example:
tabelaA = { "qualquer coisa" }
variavelA = "tabelaA"
print(variavelA)
resultado: "qualquer coisa"
Bearing in mind that I have no way to reference this table directly, I will get the string name.
Thank you very much, Dan Getz !
– DiO
@arthurgps2 tried your suggestion, but
print(shared["tabelaA"][1])
did not work here (Lua 5.1.5). Please explain more?– Dan Getz
There is also
_ENV
._ENV
and_G
are by default the same table, only_ENV
is the most commonly used by Lua, for example, when you try to access a non-local name/identifier, Lua takes the current value of_ENV
and takes the field with that name. Only Lua 5.2+ supports_ENV
(Luajit).– Klaider