MCPcopy Create free account
hub / github.com/Redot-Engine/redot-engine / run_editor_script

Method run_editor_script

editor/editor_node.cpp:5975–6008  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

5973}
5974
5975void EditorNode::run_editor_script(const Ref<Script> &p_script) {
5976 Error err = p_script->reload(true); // Always hard reload the script before running.
5977 if (err != OK || !p_script->is_valid()) {
5978 EditorToaster::get_singleton()->popup_str(TTR("Cannot run the script because it contains errors, check the output log."), EditorToaster::SEVERITY_WARNING);
5979 return;
5980 }
5981
5982 // Perform additional checks on the script to evaluate if it's runnable.
5983
5984 bool is_runnable = true;
5985 if (!ClassDB::is_parent_class(p_script->get_instance_base_type(), "EditorScript")) {
5986 is_runnable = false;
5987
5988 EditorToaster::get_singleton()->popup_str(TTR("Cannot run the script because it doesn't extend EditorScript."), EditorToaster::SEVERITY_WARNING);
5989 }
5990 if (!p_script->is_tool()) {
5991 is_runnable = false;
5992
5993 if (p_script->get_class() == "GDScript") {
5994 EditorToaster::get_singleton()->popup_str(TTR("Cannot run the script because it's not a tool script (add the @tool annotation at the top)."), EditorToaster::SEVERITY_WARNING);
5995 } else if (p_script->get_class() == "CSharpScript") {
5996 EditorToaster::get_singleton()->popup_str(TTR("Cannot run the script because it's not a tool script (add the [Tool] attribute above the class definition)."), EditorToaster::SEVERITY_WARNING);
5997 } else {
5998 EditorToaster::get_singleton()->popup_str(TTR("Cannot run the script because it's not a tool script."), EditorToaster::SEVERITY_WARNING);
5999 }
6000 }
6001 if (!is_runnable) {
6002 return;
6003 }
6004
6005 Ref<EditorScript> es = memnew(EditorScript);
6006 es->set_script(p_script);
6007 es->run();
6008}
6009
6010void EditorNode::_immediate_dialog_confirmed() {
6011 immediate_dialog_confirmed = true;

Callers 2

_menu_optionMethod · 0.80
_file_optionMethod · 0.80

Calls 9

TTRFunction · 0.85
popup_strMethod · 0.80
reloadMethod · 0.45
is_validMethod · 0.45
is_toolMethod · 0.45
get_classMethod · 0.45
set_scriptMethod · 0.45
runMethod · 0.45

Tested by

no test coverage detected