summaryrefslogtreecommitdiff
path: root/editor/editor_run_script.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'editor/editor_run_script.cpp')
-rw-r--r--editor/editor_run_script.cpp20
1 files changed, 5 insertions, 15 deletions
diff --git a/editor/editor_run_script.cpp b/editor/editor_run_script.cpp
index e2446e92be..27923ef413 100644
--- a/editor/editor_run_script.cpp
+++ b/editor/editor_run_script.cpp
@@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
+/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -60,18 +60,8 @@ Node *EditorScript::get_scene() {
}
void EditorScript::_run() {
- Ref<Script> s = get_script();
- ERR_FAIL_COND(!s.is_valid());
- if (!get_script_instance()) {
- EditorNode::add_io_error(TTR("Couldn't instance script:") + "\n " + s->get_path() + "\n" + TTR("Did you forget the 'tool' keyword?"));
- return;
- }
-
- Callable::CallError ce;
- ce.error = Callable::CallError::CALL_OK;
- get_script_instance()->call("_run", nullptr, 0, ce);
- if (ce.error != Callable::CallError::CALL_OK) {
- EditorNode::add_io_error(TTR("Couldn't run script:") + "\n " + s->get_path() + "\n" + TTR("Did you forget the '_run' method?"));
+ if (!GDVIRTUAL_CALL(_run)) {
+ EditorNode::add_io_error(TTR("Couldn't run editor script, did you forget to override the '_run' method?"));
}
}
@@ -83,7 +73,7 @@ void EditorScript::_bind_methods() {
ClassDB::bind_method(D_METHOD("add_root_node", "node"), &EditorScript::add_root_node);
ClassDB::bind_method(D_METHOD("get_scene"), &EditorScript::get_scene);
ClassDB::bind_method(D_METHOD("get_editor_interface"), &EditorScript::get_editor_interface);
- BIND_VMETHOD(MethodInfo("_run"));
+ GDVIRTUAL_BIND(_run);
}
EditorScript::EditorScript() {