From 7001d06f9d7e11e042147899acbdd01c13ad8983 Mon Sep 17 00:00:00 2001 From: "Andrii Doroshenko (Xrayez)" Date: Fri, 4 Oct 2019 00:01:12 +0300 Subject: Make `dict2inst` to work with arbitrary `_init` parameters This is achieved by skipping initializer call while creating an instance of a GDScript. This is implemented by passing -1 as an argument count to `_new` and interpreting any value below 0 to mean that the initializer should not be called during instantiation, because internal members of an instance are going to be overridden afterwards. --- modules/gdscript/gdscript_functions.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'modules/gdscript/gdscript_functions.cpp') diff --git a/modules/gdscript/gdscript_functions.cpp b/modules/gdscript/gdscript_functions.cpp index 58161d6f53..0199af642f 100644 --- a/modules/gdscript/gdscript_functions.cpp +++ b/modules/gdscript/gdscript_functions.cpp @@ -1197,8 +1197,7 @@ void GDScriptFunctions::call(Function p_func, const Variant **p_args, int p_arg_ return; } } - - r_ret = gdscr->_new(nullptr, 0, r_error); + r_ret = gdscr->_new(nullptr, -1 /*skip initializer*/, r_error); GDScriptInstance *ins = static_cast(static_cast(r_ret)->get_script_instance()); Ref gd_ref = ins->get_script(); -- cgit v1.2.3