You've already forked godot
mirror of
https://github.com/godotengine/godot.git
synced 2025-11-07 12:30:27 +00:00
Expose OS.read_string_from_stdin() to the scripting API
This can be used in scripts to read user input in a blocking manner. This also removes the unused `block` argument, which is always `true`.
This commit is contained in:
@@ -520,6 +520,10 @@ Error _OS::shell_open(String p_uri) {
|
||||
return OS::get_singleton()->shell_open(p_uri);
|
||||
};
|
||||
|
||||
String _OS::read_string_from_stdin() {
|
||||
return OS::get_singleton()->get_stdin_string();
|
||||
}
|
||||
|
||||
int _OS::execute(const String &p_path, const Vector<String> &p_arguments, bool p_blocking, Array p_output, bool p_read_stderr, bool p_open_console) {
|
||||
OS::ProcessID pid = -2;
|
||||
int exitcode = 0;
|
||||
@@ -1415,6 +1419,7 @@ void _OS::_bind_methods() {
|
||||
ClassDB::bind_method(D_METHOD("get_processor_name"), &_OS::get_processor_name);
|
||||
|
||||
ClassDB::bind_method(D_METHOD("get_executable_path"), &_OS::get_executable_path);
|
||||
ClassDB::bind_method(D_METHOD("read_string_from_stdin"), &_OS::read_string_from_stdin);
|
||||
ClassDB::bind_method(D_METHOD("execute", "path", "arguments", "blocking", "output", "read_stderr", "open_console"), &_OS::execute, DEFVAL(true), DEFVAL(Array()), DEFVAL(false), DEFVAL(false));
|
||||
ClassDB::bind_method(D_METHOD("kill", "pid"), &_OS::kill);
|
||||
ClassDB::bind_method(D_METHOD("shell_open", "uri"), &_OS::shell_open);
|
||||
|
||||
Reference in New Issue
Block a user