🎉 Celebrating 25 Years of GameDev.net! 🎉

Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!

Lua/toLua (and C++) Question about referencing tables

Started by
0 comments, last by Andrew Russell 20 years, 8 months ago
OK, say I have a table that''s an instance of a class (that has been exported by toLua). I want to access that table from my C++ (mostly so I can call functions in it). Basicly, what I need is:

gui.page["main"].element["title"] = Label:new()
gui.page["main"].element["title"].OnSomething = function(sender)
{
    -- stuff
}
 
And then to be able to call functions from C++. So really I need two things: Firstly, I need to be able to access my class''s Lua table from within its C++ class so I can call its functions in the first place. And secondly, I need to be able to pass the table of a different C++ class as an argument for sender. For instance, if I were doing it in Lua (instead of in C++), I''d go:

gui.page["main"].element["title"].OnSomething(gui.page["main"].element["alpha"])
 
Any suggestions? Free Game: Yet Another Falling Block Game
Advertisement
*bump*

So far I've had a suggestion to use LuaPlus, and comments?



Can I do this:
-- the refrence to the table in lua would look like:gui.page["main"].element["title"].onSomething(gui.page["main"].element["button"]) 
// in C++, can I do this:lua_pushstring(L, "gui.page[\"main\"].element[\"title\"].onSomething");lua_pushstring(L, "gui.page[\"main\"].element[\"button\"]");lua_call(L, 1, 1); 

Of course, I could push a formatted string to make things eaiser. My only issue is that all this string passing could be slow.

Ideas?

Free Game: Yet Another Falling Block Game

[edited by - Andrew Russell on October 22, 2003 10:40:13 PM]

This topic is closed to new replies.

Advertisement