Better error handling when resolving _generate_name
This commit is contained in:
parent
899335d1fe
commit
654eda1c65
|
@ -128,9 +128,17 @@ String BTTask::get_task_name() {
|
||||||
}
|
}
|
||||||
return _generate_name();
|
return _generate_name();
|
||||||
#elif LIMBOAI_GDEXTENSION
|
#elif LIMBOAI_GDEXTENSION
|
||||||
String s;
|
Ref<Script> task_script = get_script();
|
||||||
VCALL_OR_NATIVE_V(_generate_name, String, s);
|
if (task_script.is_valid() && task_script->is_tool()) {
|
||||||
return s;
|
Variant call_result;
|
||||||
|
VCALL_OR_NATIVE_V(_generate_name, Variant, call_result);
|
||||||
|
ERR_FAIL_COND_V(call_result.get_type() == Variant::NIL, _generate_name());
|
||||||
|
String task_name = call_result;
|
||||||
|
ERR_FAIL_COND_V(task_name.is_empty(), _generate_name());
|
||||||
|
return task_name;
|
||||||
|
} else {
|
||||||
|
return _generate_name();
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
return data.custom_name;
|
return data.custom_name;
|
||||||
|
@ -343,7 +351,10 @@ PackedStringArray BTTask::get_configuration_warnings() {
|
||||||
PackedStringArray ret;
|
PackedStringArray ret;
|
||||||
|
|
||||||
PackedStringArray warnings;
|
PackedStringArray warnings;
|
||||||
|
Ref<Script> task_script = get_script();
|
||||||
|
if (task_script.is_valid() && task_script->is_tool()) {
|
||||||
VCALL_V(_get_configuration_warnings, warnings); // Get script warnings.
|
VCALL_V(_get_configuration_warnings, warnings); // Get script warnings.
|
||||||
|
}
|
||||||
ret.append_array(warnings);
|
ret.append_array(warnings);
|
||||||
ret.append_array(_get_configuration_warnings());
|
ret.append_array(_get_configuration_warnings());
|
||||||
|
|
||||||
|
|
|
@ -124,7 +124,7 @@ Ref<BTTask> LimboAIEditor::_create_task_by_class_or_path(const String &p_class_o
|
||||||
|
|
||||||
if (p_class_or_path.begins_with("res:")) {
|
if (p_class_or_path.begins_with("res:")) {
|
||||||
Ref<Script> s = RESOURCE_LOAD(p_class_or_path, "Script");
|
Ref<Script> s = RESOURCE_LOAD(p_class_or_path, "Script");
|
||||||
ERR_FAIL_COND_V_MSG(s.is_null() || !s->can_instantiate(), nullptr, vformat("LimboAI: Failed to instantiate task. Bad script: %s", p_class_or_path));
|
ERR_FAIL_COND_V_MSG(s.is_null(), nullptr, vformat("LimboAI: Failed to instantiate task. Bad script: %s", p_class_or_path));
|
||||||
Variant inst = ClassDB::instantiate(s->get_instance_base_type());
|
Variant inst = ClassDB::instantiate(s->get_instance_base_type());
|
||||||
ERR_FAIL_COND_V_MSG(inst == Variant(), nullptr, vformat("LimboAI: Failed to instantiate base type \"%s\".", s->get_instance_base_type()));
|
ERR_FAIL_COND_V_MSG(inst == Variant(), nullptr, vformat("LimboAI: Failed to instantiate base type \"%s\".", s->get_instance_base_type()));
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue