lua-users home
lua-l archive

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


I wouldn't think you could continually re-evaluate the position of the
target.  Otherwise if the target never stops moving you will never
complete your action.

Perhaps a snapshot approach would work best.  Especially since the lua
script should be executing in the millisecond range so you aren't
talking about macro-scale movements or anything.

- Jason


On 7/20/05, Ive <neosettlers@sympatico.ca> wrote:
> There s one thing I m confuse about game ai...
> 
> Let says u chasing a big bear in the mountains... the ai for the bear
> changes is position when he is in your line of sight...
> 
> u lost it after falling in a pit or something... the bear is obviously
> not passed in the render pipeline... is the ai still updating? Yes of
> course... depends... not at all... predictions? You don't see him but
> another player could see it...(assuming multiplayer). I m currently
> laying and studying WOW... which by the way use lua.
> 
> When u come back... taking for granted the bear did not stop to smell
> flowers... it should have change position since the last time you saw
> him... u cant stop and resume the ai for this....
> 
> it means that for each actor u could possibly meet in your adventure the
> ai for all actors should update all the time... at least for position?
> That's a scary thought!
> 
> 
> Now I have one global state... and for ai a simply call a function!
> 
> But im still not sure either to use:
> 
>        lua_pushstring(m_lua, in_function.GetName());
>        lua_gettable(m_lua, LUA_GLOBALSINDEX);
>        lua_pcall(m_lua, 0, 0, 0);
> 
> or
> 
>        lua_getglobal(m_lua, in_function.GetName());
>        lua_pcall(m_lua, 0, 0, 0);
> 
> both work fine! Any preference?
> 
> thx
> 
> -----Original Message-----
> From: lua-bounces@bazar2.conectiva.com.br
> [mailto:lua-bounces@bazar2.conectiva.com.br] On Behalf Of Antoine
> Chavasse
> Sent: Wednesday, July 20, 2005 2:09 PM
> To: Lua list
> Subject: Re: Attach Lua script To C++ class!
> 
> On 7/20/05, Ive <neosettlers@sympatico.ca> wrote:
> > Hey thx for your help!
> >
> > I have to solve the issue of using either one global lua_state or
> having
> > one lua_sate per script!
> >
> > What s the difference? Anyone can clear this up?
> >
> 
> If you have one per script, they can yield and be resumed
> independently, so you can do things like stopping a script half-way to
> resume its execution later, but you can still execute other scripts in
> the meantime.
> 
> As I understand what you want to do from your first post, you want to
> have one script per actor, and each time they are executed, they
> update the actor's state.
> I don't think you really need several different lua_State to do that.
> 
> In the project I'm working on, I didn't want the scripters to have to
> explicitely write state machines, so I chose another approach where
> the scripts call functions to initiate one or more action, are
> suspended, and resumed when the action is finished.
> 
> 
>