How do I do this?

This topic is 4507 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

Recommended Posts

I'm working on a small old-school SNES-style RPG in C#, probably using Lua for scripting (since I already know Lua). What I want to be able to do is write something like
engine.show_message('this is a message')
and not have the function return until the user has dismissed the message. I'm using LuaInterface for my C#-to-Lua binding.

Share on other sites
You need to yield from the show_message function, inside a Lua co-routine, then resume it from the C# engine when you want the script to continue.

Share on other sites
Being new to this, could you give me some pointers on how to do that? I know what a coroutine is, I'm just not sure how to do this with one.

Share on other sites
The co-routine merely 'remembers your place' in the Lua code (in this example, the end of the show_message function) while you're back executing the C# code. Then when you need to continue with the script, the C# engine resumes the coroutine, which continues, presumably leaving show_message and calling the next function.

Check out this thread which might give you some ideas.