Closed Krangth closed 7 years ago
To create an input you can use "QueryParam" function inside a command.
There is an example of this in the "SomeItemCommand" class. See the Sample code.
The "QueryParam" is generic and you can choose the return type. You can also provide "param" that will create a default value for a command. And you can provide options (selectable with the tab-key) as a dictionary.
I will add some more input examples on the README.md as well.
The idea with Tharga.Console is to create commands and use the QueryParam function. But, you might be right... Perhaps System.Console.ReadLine() should work too. Do you want to give it a try, and add it to the source code? :)
Now I have added some input examples.
I also pushed an experiment on the develop branch where you can use...
var line = console.ReadLine();
What do you think about that?
The problem with this approach is that it blocks the console. The idea of using commands is that there can be background threads running at the same time as you are typing stuff. It is all handled by the input manager and the textbuffer is moved.
Try to use a command as in the examples first, if this does not work for your needs, please tell me. Perhaps we can work it out.
I'm having trouble figuring out how to read a string from the console even after viewing the source. As you probably know, System.Console.ReadLine() does not work most likely due to the robust threading. I noticed there is an InputManager.Readline, but it is internal.
Is there any advice on reading a string from the user? Or is that simply not supported.
ps. really like the console