[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: lua threads resuming and yielding from C
- From: "Alex Davies" <alex.mania@...>
- Date: Thu, 13 Mar 2008 20:21:32 +0900
I couldn't fully understand your post, but I think I understand the error
message and "hook".
Lua can only yield if the C call stack is empty. This means you cannot yield
from inside a metamethod, eg __index, or from a nested C call, or, in this
case, from a hook. If you really require this, you need a dedicated C stack
for all lua threads, eg you need coco. http://luajit.org/coco.html
This solution increases memory usage somewhat. Future versions of jit
promise a better approach if IIRC.
----- Original Message -----
From: "Joseph Saadé" <email@example.com>
Sent: Thursday, March 13, 2008 6:19 PM
Subject: lua threads resuming and yielding from C
In my game project every entity has a different script running in a
new lua thread.
Every game loop, the engine calls the function OnUpdate located in every
I want the ability to pause a script.
I implemented that by using a script manager that keeps track if a
script is yield.
so somthing like this would work:
Entity.Pause is a C hook function that pauses the thread execution
the script engine waits 3 seconds and then calls lua_resume.
The function OnUpdate is not called while is script is yielding.
my problem is that after the script first resumes, the doAI2() is not
called, nothing after the pause command is actually called. and the
next call to yield/resume will resolve in an error (yield returns:
"attempt to yield across metamethod/c-call boundary")
so can't i yield a thread from inside a hook function and resume it's