Getting Lumberyard to wait for input, in Lua?

I’m looking to emulate the behaviour of standard Lua ‘’ functionality - as in the following example.

   local answer
io.write("continue with this operation (y/n)? ")
until answer=="y" or answer=="n"

This doesn’t seem to work out of the box - Lumberyard hangs forever without the ability to input anything. Basically I’d like to hook into the UI Canvas OnAction system (be it from a button press, text box ‘enter’, whatever) and have the engine wait until a certain OnAction event has been triggered before continuing as normal. Here’s some pseudocode of what I’m looking for:

  ... earlier code
while (inputNotReceived) do
if (playerInput == something) then

I’ve looked into coroutines for this as well, however they seem to behave extremely strangely in Lumberyard and can’t seem to be counted on to work properly.

Hi @AlexKane,

I think what is happening there is that the Lua loop will prevent anything else updating at the same time. Is there a different way you can approach the problem - e.g. by pausing the game and then when you get the UI action you are waiting for unpausing the game? Presumably you want the UI system to update and render during this time? You can also listen on the TickBus if you need to execute some Lua each frame while waiting.
In the upcoming v1.9 release you can do a lot more with Lua and the UI system which may help.