[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: RE: Attach Lua script To C++ class!
- From: "Richard Ranft" <rranft@...>
- Date: Wed, 20 Jul 2005 18:15:28 -0700
Um, you can use a single Lua state, and then spawn "child states" from it.
Less overhead (I'm reporting third-hand knowledge) and you can still yield
and resume scripts. See my other post from today for an example (attached
code from GPG5).
Rich
-----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 11:09 AM
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.