lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]



You can use loadstring, i.e.

Lua 5.1.1  Copyright (C) 1994-2006 Lua.org, PUC-Rio
> t = {a = true}
> =loadstring("return t.a")()
true
>

In your case something like this should work:

loadstring("return " .. path_to_n2)()

On 12/1/06, wang xu <xu4wang@gmail.com> wrote:
Hello,

If I have a string containing the path to a varialble, for example:

> n1={n2="hello"}
> =n1.n2
hello
> path_to_n2="n1.n2"
> print(path_to_n2)
n1.n2
>

Given variable path_to_n2, how can I get the value of n1.n2 ?