From e9ce9a842284f68011f64a7ab23d0a25511f133c Mon Sep 17 00:00:00 2001 From: Bastiaan Olij Date: Thu, 25 Feb 2021 22:05:16 +1100 Subject: [PATCH] Expose set_environment to GDScript --- core/bind/core_bind.cpp | 6 ++++++ core/bind/core_bind.h | 1 + doc/classes/OS.xml | 11 +++++++++++ 3 files changed, 18 insertions(+) diff --git a/core/bind/core_bind.cpp b/core/bind/core_bind.cpp index c0406b738e..22de9d8ac3 100644 --- a/core/bind/core_bind.cpp +++ b/core/bind/core_bind.cpp @@ -548,6 +548,11 @@ String _OS::get_environment(const String &p_var) const { return OS::get_singleton()->get_environment(p_var); } +bool _OS::set_environment(const String &p_var, const String &p_value) const { + + return OS::get_singleton()->set_environment(p_var, p_value); +} + String _OS::get_name() const { return OS::get_singleton()->get_name(); @@ -1343,6 +1348,7 @@ void _OS::_bind_methods() { ClassDB::bind_method(D_METHOD("get_process_id"), &_OS::get_process_id); ClassDB::bind_method(D_METHOD("get_environment", "environment"), &_OS::get_environment); + ClassDB::bind_method(D_METHOD("set_environment", "environment", "value"), &_OS::set_environment); ClassDB::bind_method(D_METHOD("has_environment", "environment"), &_OS::has_environment); ClassDB::bind_method(D_METHOD("get_name"), &_OS::get_name); diff --git a/core/bind/core_bind.h b/core/bind/core_bind.h index b62de00303..7ba784f424 100644 --- a/core/bind/core_bind.h +++ b/core/bind/core_bind.h @@ -250,6 +250,7 @@ public: bool has_environment(const String &p_var) const; String get_environment(const String &p_var) const; + bool set_environment(const String &p_var, const String &p_value) const; String get_name() const; Vector get_cmdline_args(); diff --git a/doc/classes/OS.xml b/doc/classes/OS.xml index ce01a1a3a0..9ede31bffb 100644 --- a/doc/classes/OS.xml +++ b/doc/classes/OS.xml @@ -914,6 +914,17 @@ [b]Note:[/b] This method is implemented on Android. + + + + + + + + + Change the value of an environment variable. + +