inkle / ink

inkle's open source scripting language for writing interactive narrative.
http://www.inklestudios.com/ink
MIT License
3.97k stars 482 forks source link

Asynchronous function execution #898

Open 15sawyer opened 3 months ago

15sawyer commented 3 months ago

Hello, I have a specific use case and wanted to ask about the suggested solution.

Use case: At some point, I want to interrupt the story flow and wait until the player inputs something (e.g. clicks on a specific button).

Current approach: Currently, I run an external function that sets a wait flag. While the wait flag is set, no more lines are read.

Disadvantages: The disadvantages of this approach are that it requires unnecessary global variables to get some return value from code and that the story doesn't wait until the next line is read, meaning I can't use the "returned" value inside it.

In other languages, this would be solved using asynchronous functions. What's the best solution to this in Ink?