How to find if table have other table in it with specified name?
Or how to conver table "var1" in table "t" into string? And use "for" loop with "if" to find it.
input = "var1"
local t = {
var1 = {[..content..]},
var2 = {[..content..]},
var3 = {[..content..]},
};
Now how to find, if table "t" have table "var1"?
>Solution :
Extending on Mikes comment: indexing a table with a non existing key returns nil. See https://www.lua.org/pil/2.5.html
And since nil evaluates to false checking for existing keys is as simple as
if t["var1"] then
Or when the identifier is valid:
if t.var1 then
If you want to make sure var1 is a table only:
if type(t.var1) == "table" then
See https://www.lua.org/pil/2.html