Advertisement

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

Started by October 19, 2003 05:53 AM
0 comments, last by Andrew Russell 21 years, 1 month 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
*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