Fix: Create script template not working as expected

This commit is contained in:
Serhii Snitsaruk 2024-01-10 15:23:04 +01:00
parent 68b2aaf9d5
commit 59537138bc
2 changed files with 9 additions and 2 deletions

View File

@ -611,7 +611,7 @@ void LimboAIEditor::_misc_option_selected(int p_id) {
if (!FILE_EXISTS(template_path)) {
if (!DirAccess::dir_exists_absolute(template_dir)) {
Error err = DirAccess::make_dir_absolute(template_dir);
Error err = DirAccess::make_dir_recursive_absolute(template_dir);
ERR_FAIL_COND(err != OK);
}
@ -644,12 +644,18 @@ void LimboAIEditor::_misc_option_selected(int p_id) {
"\n\n"
"# Called each time this task is ticked (aka executed).\n"
"func _tick(delta: float) -> Status:\n"
"_TS_return SUCCESS\n";
"_TS_return SUCCESS\n"
"\n\n"
"# Strings returned from this method are displayed as warnings in the behavior tree editor (requires @tool).\n"
"func _get_configuration_warnings() -> PackedStringArray:\n"
"_TS_var warnings := PackedStringArray()\n"
"_TS_return warnings\n";
f->store_string(script_template);
f->close();
}
EDITOR_FILE_SYSTEM()->scan();
EDIT_SCRIPT(template_path);
} break;
}

View File

@ -54,6 +54,7 @@ void EDIT_SCRIPT(const String &p_path) {
Ref<Script> res = RESOURCE_LOAD(p_path, "Script");
ERR_FAIL_COND_MSG(res.is_null(), "Failed to load script: " + p_path);
EditorInterface::get_singleton()->edit_script(res);
EditorInterface::get_singleton()->set_main_screen_editor("Script");
}
Variant _GLOBAL_DEF(const String &p_var, const Variant &p_default, bool p_restart_if_changed, bool p_ignore_value_in_docs, bool p_basic, bool p_internal) {