XLua Coroutine problem

Welcome to our brand new Clickteam Community Hub! We hope you will enjoy using the new features, which we will be further expanding in the coming months.

A few features including Passport are unavailable initially whilst we monitor stability of the new platform, we hope to bring these online very soon. Small issues will crop up following the import from our old system, including some message formatting, translation accuracy and other things.

Thank you for your patience whilst we've worked on this and we look forward to more exciting community developments soon!

Clickteam.
  • Hi all. I'm trying to use coroutines in xlua similar to how zephni uses them in his normal lua extension tutorials on the daily click:

    script = coroutine.create(runscript);

    function pausescript()
    coroutine.yield(script);
    end

    function resumescript()
    coroutine.resume(script);
    end

    however, when I run the application xlua returns an invalid return request error, that goes away when I delete the coroutine.create action, and when i actually try to use pausescript() and resumescript() in functions, i get a really long error string. I am using xlua version 1.5.2 and latest update MMF2 developer. I really need coroutines for my application, is there something im doing wrong? I haven't had any problems coding with xlua up until this point...

    Best person at writing incomprehensible posts. Edits are a regularity.

    Edited once, last by casleziro (March 25, 2013 at 4:04 PM).

  • i eliminated the coroutine.create problem by creating a function named runscript to use, but when i call script yields i still get an "attempt to yield across metamethod/c-call boundary" error...

    Best person at writing incomprehensible posts. Edits are a regularity.

  • Last I knew, coroutines should have been able to cross the event boundary. That's the main reason I haven't considered upgrading to LuaJIT 2 -- they removed the ability to propagate co-routines across the C API (and thus, across the event boundary). I don't remember if LuaJIT is enabled by default in the extension, but it probably needs to be.

    There might be some XLua-specific tutorials floating around somewhere for working with coroutines. Possibly search the file archive.
    Try here: Please login to see this link.

  • hi retriever2, thank you for responding. I fixed my problem, but i had to go about it in a weird way:

    instead of using an embedded script for the coroutine functions themselves, I had to write an external script and then load it into lua every time I wanted to use it. It's odd, but it worked :S

    so it would appear coroutines do in fact work in xlua, only not in embedded scripts? (sorry for not making it clear that I was attempting to use them in embedded scripts in the OP, my bad)

    Best person at writing incomprehensible posts. Edits are a regularity.

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!