lua-users home
lua-l archive

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


Brandon,

for lua yield, the nresults param would be the number of results the c function would be returning to the script, which would be pushed onto the stack beforehand. In your case this can probably be 0

as for lua resume, this is the number of arguments that would be pushed into the script (if the script were being started with lua_resume, such as a thread is), in your case this can also be 0.

if this doesn't work for you, then I would assume it's not working because you're not using co-routines.

-Raymond

On Tue, Jul 8, 2008 at 10:44 AM, Brandon <winterknight@nerdshack.com> wrote:
On Tue, 8 Jul 2008 10:30:42 -0400
"Raymond Jacobs" <raymondj@gmail.com> wrote:

> Hi there,
>
> Within the add function, you would call lua_yield, and return it's
> return value.
>
> later you would use lua_resume to resume the thread.
>
> as for what to pass into lua_yield and lua_resume, I'd suggest you
> read the lua programming reference for those functions
>
> http://www.lua.org/manual/5.1/
>
> hope that helps.
>
> -Raymond

Thanks for trying to help, but you seem to have completely missed my
problem. I already know TO use lua_yield and lua_resume. I'm wondering
HOW. As for "reading the reference", I did that before I came here. It
mentions nargs and nresults, but doesn't say what they are. I tried my
best to figure it out, and tried several pieces of code. I have already
explained what I tried in detail. I think that the first missing piece
would be: "return lua_yield(L, 1)". Like I said, I can halt execution
of the script, but can't figure out how to resume it again. I've tried
putting "lua_resume(L, x)" into cont(), where x is everything
reasonable I could think of (I've treid every value between -5 and 10).
I just can't seem to resume it.

I didn't include lua_yield() in the sample code, because I couldn't be
sure that I was doing it right. Perhaps I was yielding in such a way
that I couldn't return.

As for lua_newthread(), I'll look that up.

-Brandon