-
Notifications
You must be signed in to change notification settings - Fork 117
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
How do I create a table from C++? #170
Comments
So far i'm doing this :
But I'ld love a better way, indeed :) |
Oh my...that's awful! lol |
I was experimenting the following, although I'm unsure whether or not I'm going to use this code in my project: int counter = 0;
// ...
state(std::string("x" + std::to_string(++counter) + " = Object:new()").c_str());
sel::Selector tableReference = state[std::string("x" + std::to_string(counter)).c_str()]; Here I call a user-defined new method from a Lua do_string that contains the x char and concatenate it into a counter that tells how many tables have been instantiated in the program so that they may have unique identifiers. My first solution was creating a Lua VM for each instance of my table since each VM maintains its own state. I was not sure if creating many VMs is going to have a significant impact on performance so I played it safe by looking for other ways. The big advantages here were that the states were self-contained, there was no need for manual memory handling and the code just looked better. Oh well. |
Its not clear to me how to create a table in the Lua environment from C++...
The text was updated successfully, but these errors were encountered: