[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: lua threads resuming and yielding from C
- From: "Joseph Saadé" <jsaade@...>
- Date: Thu, 13 Mar 2008 01:19:57 -0800
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 script.
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:
function OnUpdate(dt)
doAI()
Entity.Pause(3)
doAI2()
end
Entity.Pause is a C hook function that pauses the thread execution
using lua_yield.
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
execution normally?