lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


At 08:07 PM 1/5/2004, you wrote:
Hi.

hi.

I don't know how to use tolua to instantiate structs (not objects) in my lua scripts.
[...]
How do you create a variable of the above type and initialize it? I tried with the type:new() sintax, but it seems that's only for classes.

on c++, only classes (and structs) with a constructor will have a 'new()' method.. You can add the constructor on your pkg (even if it's not actually implemented). For C structs the only solution I can think of is to have a function that creates a new struct and returns it. example:

CCLIB_START_STRUCT* get_new_CCLIB_START_STRUCT(char* lib_name="");

you can have default parameters for C functions on tolua, so you can also use it to get the struct alredy initialized.

Greetings
Ignacio Burgueño

Hope that helps..

Ariel.

Ariel.
http://Anime.com.ar
snm