diff options
author | RĂ©mi Verschelde <rverschelde@gmail.com> | 2017-08-17 07:31:13 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-08-17 07:31:13 +0200 |
commit | a5604130c55e099e831ba6d2bd5cee578cac16f2 (patch) | |
tree | 6eb2a79f94874c30831250ce82b9c23cde411708 | |
parent | 19aff15a1af27a428c82f4a30dea498be9319de1 (diff) | |
parent | fcf52303c52901bf4844e0491538402672b71be1 (diff) |
Merge pull request #10385 from RandomShaper/improve-prop-eval
Fix/improve property evaluator
-rw-r--r-- | editor/property_editor.cpp | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/editor/property_editor.cpp b/editor/property_editor.cpp index d6c1407b62..2f47d3e130 100644 --- a/editor/property_editor.cpp +++ b/editor/property_editor.cpp @@ -4774,19 +4774,20 @@ double PropertyValueEvaluator::eval(const String &p_text) { return _default_eval(p_text); } - ScriptInstance *script_instance = script->instance_create(obj); + Object dummy; + ScriptInstance *script_instance = script->instance_create(&dummy); if (!script_instance) return _default_eval(p_text); Variant::CallError call_err; - double result = script_instance->call("e", NULL, 0, call_err); + Variant arg = obj; + const Variant *args[] = { &arg }; + double result = script_instance->call("eval", args, 1, call_err); if (call_err.error == Variant::CallError::CALL_OK) { return result; } print_line("[PropertyValueEvaluator]: Error eval! Error code: " + itos(call_err.error)); - memdelete(script_instance); - return _default_eval(p_text); } @@ -4795,9 +4796,8 @@ void PropertyValueEvaluator::edit(Object *p_obj) { } String PropertyValueEvaluator::_build_script(const String &p_text) { - String script_text = "tool\nextends Object\nfunc e():\n\treturn "; - script_text += p_text.strip_edges(); - script_text += "\n"; + String script_text = + "tool\nextends Object\nfunc eval(s):\n\tself = s\n\treturn " + p_text.strip_edges() + "\n"; return script_text; } |