summaryrefslogtreecommitdiff
path: root/editor
diff options
context:
space:
mode:
authorPedro J. Estébanez <pedrojrulez@gmail.com>2017-08-16 03:01:41 +0200
committerPedro J. Estébanez <pedrojrulez@gmail.com>2017-08-16 03:01:41 +0200
commitae2d4490472a129b2f7d73efac0b4dbf257a8018 (patch)
tree731394cbcffc695979109f62f02fc417584c51bc /editor
parent6380975ee277db907c52a9aa621c01281b5c12d4 (diff)
Revive inspector property evaluation
GDScript was restricted to parse only scripts beginning with __res://__ or __user://__ to avoid templates from being parsed. I've made that a bit less inclusive by allowing scripts with an empty path to be parsed too, which doesn't conflict and is needed for this to work. Also I've removed the `this` variable of the generated script and made the relevant object to be the one the script instance refers to, so you can use `self` instead. Now, with the shorter 3.0-style syntax, you can write things like: `self.position.x + 10` Closes #9500.
Diffstat (limited to 'editor')
-rw-r--r--editor/property_editor.cpp5
1 files changed, 2 insertions, 3 deletions
diff --git a/editor/property_editor.cpp b/editor/property_editor.cpp
index 0176f606d6..e791fa48c8 100644
--- a/editor/property_editor.cpp
+++ b/editor/property_editor.cpp
@@ -4774,12 +4774,11 @@ double PropertyValueEvaluator::eval(const String &p_text) {
return _default_eval(p_text);
}
- ScriptInstance *script_instance = script->instance_create(this);
+ ScriptInstance *script_instance = script->instance_create(obj);
if (!script_instance)
return _default_eval(p_text);
Variant::CallError call_err;
- script_instance->call("set_this", obj);
double result = script_instance->call("e", NULL, 0, call_err);
if (call_err.error == Variant::CallError::CALL_OK) {
return result;
@@ -4796,7 +4795,7 @@ void PropertyValueEvaluator::edit(Object *p_obj) {
}
String PropertyValueEvaluator::_build_script(const String &p_text) {
- String script_text = "tool\nvar this\nfunc set_this(p_this):\n\tthis=p_this\nfunc e():\n\treturn ";
+ String script_text = "tool\nextends Object\nfunc e():\n\treturn ";
script_text += p_text.strip_edges();
script_text += "\n";
return script_text;