[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: noob - How to architect c++ code to use lua as external code
- From: Kevin Martin <kev82@...>
- Date: Mon, 22 Oct 2012 18:48:02 +0100
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