[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Newbie question
- From: "simonroper3" <simonroper3@...>
- Date: Sat, 23 Feb 2002 20:56:11 -0000
Hi, i've just started with LUA so apologies if this has been covered
somewhere before, i have read the manual and looked over the net but
i'm struggling to figure this out.
Basically i want to create instances of objects that i have defined
in C/C++ code they maybe defined as classes but i handle all the
conversion and copying of data myself once i have the parameters...
I have everything working as follows:
In my lua script i have something like the following
Button = {}
Button["Button1"] = { }
Button["Button1"].x = 10;
Button["Button1"].y = 15;
Button["Button1"].OnTest = Button1_OnTest;
NewButton(Button["Button1"]);
function Button1_OnTest()
print("test");
end;
NewButton is a call to a function of mine which pulls off all the
parameters and stores them in my newly created object..
The problem i have is calling the 'Button1_OnTest' function from C
side..
i can of course store the function as a string and use
lua_getglobal(L, "Button1_OnTest");
lua_call(L,0,0);
which works, however is it possible to store off the pointer and
call that pointer at a later date otherwise i have to build up the
string when the button is registered...
I've tried grabbing the data off the stack and the only thing that
returns me a pointer is lua_topointer..all other data retrieval
calls return 0 even though says there is a LUA_TFUNCTION present.
Am i going about this the wrong way?
regards