Yield from host application

Aug 29, 2015 at 3:39 PM
Hello. I'm wondering if a feature I love about C Lua is possible in NeoLua, or other DLR Lua implementations. That feature is: yielding from the host application, to wait for a response from the user.

For example, the Lua code is running on a server, sending messages to clients, and the scripts have to wait for the user to select something before the script continues.
sendOptions("foobar", "barfoo")
if(select() == "foobar")
    ...
In C Lua you can do this by calling lua_yield in the host, which is beautiful, because there's no need for additional code in the scripts.

I've accomplished this before with C# "scripts", utilizing await/async, which makes me think that it might be possible on the DLR. But is it? And is it possible without additional code in the scripts, maybe awaiting automatically if the called method is async? Does NeoLua maybe support this already and I haven't found how yet?

Looking forward to your answer^^

Thanks,
exec
Coordinator
Aug 30, 2015 at 1:17 PM
Hello,

I do not understand what you mean with host/client and how far they away.

But you can use the LuaThread class. This class implements the resume/yield stuff and is useable from both sites of the world.

The await/async stuff is on my wish list, to make this more .net, but it is a hard topic. I have to create a state machine in the background to split the lua code. But it should possible to use the Task's, but I never tried it.

Have I nice weekend.
Neo