[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: RE: Yielding
- From: "Matthew Harmon" <matt@...>
- Date: Fri, 13 Aug 2004 16:33:22 -0500
You can call lua_yield() as the last statement of your glue routine. Below
is one of my glue routines that let's my script yield for a given time
period.
static int LuaWaitSec(lua_State* l)
{
// grab a pointer to the correct manager object
// from the GLOBAL table in this state
s = GetScriptManagerObject();
// signal the manager that we're waiting for x seconds
s->waitTimestamp = s->time + lua_tonumber(1);
s->state = LSS_WAITTIME;
// yield control, our eventual resume() will push one value on the stack
return(lua_yield(l, 1));
}
-----Original Message-----
From: lua-bounces@bazar2.conectiva.com.br
[mailto:lua-bounces@bazar2.conectiva.com.br] On Behalf Of John Paquin
Sent: Friday, August 13, 2004 4:24 PM
To: LuaList
Subject: Yielding
I know this has been covered before, but I can't seem to find it in the
archives.
Is there any way to do a yield (or something like it) from c that has
been called from Lua?
In my game, I want to do something like this from lua:
player.newpath = pathfinder.makepath(pointa,pointb)
I want the Lua code to return only when it has a path.
On the c side, however, I want to add the makepath request to the
pathfinder's queue, then "yield".
The pathfinder would then complete the request incrementally while the
game continues to run. When the path is complete, the c code would then
"resume" the Lua code.
Is there a way to do this?