# How do I do this?

## Recommended Posts

trevaaar    235
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
Kylotan    10013
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
trevaaar    235
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
Kylotan    10013
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.

## Create an account

Register a new account