lua-users home
lua-l archive

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


On Mon, Oct 22, 2012 at 10:48 AM, Kevin Martin <kev82@khn.org.uk> wrote:
>
> On 22 Oct 2012, at 18:16, Giuliano Suminsky wrote:
>
>> I like your way much more than mine. The thing is the OO x lua static
>> only functions..whats the best way to communicate the c++ agent
>
> There is a chapter in Programming in Lua that covers this kind of stuff, I suggest you start by reading that.
>
> Essentially, maintain a separate Lua state for each AI, and store the pointer to the c++ object in the registry under a specific known key (I use uuidgen for keys) then implement some plain C functions which retrieve the this pointer and forward the call to the C++ object with converted parameters (so you're not passing the Lua stack around) if necessary.
>
> Thanks,
> Kev

Why use something as clumsy as a UUID for the key when you get a
unique ID back from luaL_ref?

/s/ Adam