Nested coroutines
So I need to run a coroutine that endlessly calls another coroutine like so:
public IEnumerator terminal_command(string[] args)
{
terminal.println("running terminal", Terminal.success_style);
// Loop forever to wait for inputs
while (!terminal.window.active)
{
string input_string = null;
//terminal.println(">", Terminal.warning_style);
yield return StartCoroutine(terminal.getline((x) => input_string = x));
//terminal.println("hello " + input_string, Terminal.success_style);
terminal.println("meme", Terminal.warning_style);
}
yield return null;
}
public IEnumerator getline(System.Action<string> var)
{
enable_command_parsing(false);
while (!submitted)
{
yield return null;
}
string str = "";
foreach (TChar tc in line_buffer.get_buffer()[(int)cursor_pos.y - 1].chars)
{
str += tc.c;
}
var(str);
enable_command_parsing(true);
}
esentially the getline waits for the user to press enter, then returns. However, in 'terminal_command', it calls terminal.getline once, and then just exits, when I want it to loop until the window is not active
Comment