lua-users home
lua-l archive

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

Hi, Im fairly new to lua so excuse me if I ask something silly.

Im using lua to script my game, but I encopunter a problem, I got a 
struct magic_power defined that contains a few fields.

Now I have this function that needs to be called from lua with a table
of magic_power:

int get_magic_power_lua(int *sn, magic_power *powers, int 
max_powers, char *lua_desc);

Now in my lua code I do:
t = {name = "zog", ...}
t = tolua.cast(t, "magic_power")
tm = {}
tm[0] = t
tm = tolua.cast(tm, "magic_power")

ret, sn = get_magic_power_lua(0, tm, 1, "desc_test")

load loads and execute it fine .. exepct that the powers pointer is 
set to NULL .. which is *QUITE* annoying ..

So basically how do I declare a tablme/struct in lua based on a C 
type so I can pass it to C funtions ?


PS: I use tolua to externalize the API and lua 3.2

DarkGod comes from     | Do not meddle in the affairs of wizards
the hells for YOU ! :) | because they are subtle and quick to anger.
Pe W Olorin YSo L:50 DL:696 A+++ R+++ Sp++ w:Mage Staff of Mana(240%)
Pe*/M(Km)(Cr)(NH) D H- D c++ f- PV s- TT- d++ P++ M+ C- S++ I+++ So++ B/-
ac- GHB- SQ+ RQ V+++ F:Mage playing Mage-like(see Pernangband Sorcerors)
______________________________________________________________________________, l'email gratuit le plus complet de l'Internet !
vos emails depuis un navigateur, en POP3, sur Minitel, sur le WAP...