Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Access subtables directly #67

Closed
Sygmei opened this issue Jul 25, 2017 · 3 comments
Closed

Access subtables directly #67

Sygmei opened this issue Jul 25, 2017 · 3 comments

Comments

@Sygmei
Copy link

Sygmei commented Jul 25, 2017

Is there another way to access a subtable ?

I know you can do :

luavm["a"]["b"]["c"] = 10;

But is it possible to do something like :

std::string path = "a.b.c";
luavm.access(path);

?

@OvermindDL1
Copy link

Nested tables are actually tables inside tables, they are not keyed based on the full path. Doing a dot access like that needs to be run 'inside' the lua vm, so you can access it just be executing inside the vm a string of that form as that is what would have to be done anyway.

@satoren
Copy link
Owner

satoren commented Jul 25, 2017

std::string path = "a.b.c";
kaguya::LuaRef value = luavm.loadstring("return "+path)(); // get
luavm.loadstring(path + "= ...")("newvalue"); // set

@Sygmei
Copy link
Author

Sygmei commented Jul 25, 2017

What I needed ! Thank you :)

@Sygmei Sygmei closed this as completed Jul 25, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants