Update variables demo and small fixes

This commit is contained in:
Serhii Snitsaruk 2023-08-08 15:07:02 +02:00
parent 2795c6dcf2
commit afe210b014
3 changed files with 38 additions and 7 deletions

View File

@ -72,6 +72,7 @@ Variant BBParam::get_value(Object *p_agent, const Ref<Blackboard> &p_blackboard,
if (value_source == SAVED_VALUE) {
return saved_value;
} else {
ERR_FAIL_COND_V_MSG(!p_blackboard->has_var(variable), Variant(), vformat("BBParam: Blackboard variable doesn't exist: \"%s\".", p_default));
return p_blackboard->get_var(variable, p_default);
}
}

View File

@ -19,7 +19,7 @@ String BTSetVar::_generate_name() const {
if (variable.is_empty()) {
return "SetVar ???";
}
return vformat("SetVar %s = %s", LimboUtility::get_singleton()->decorate_var(variable),
return vformat("Set %s = %s", LimboUtility::get_singleton()->decorate_var(variable),
value.is_valid() ? Variant(value) : Variant("???"));
}

View File

@ -1,4 +1,34 @@
[gd_resource type="BehaviorTree" load_steps=6 format=3 uid="uid://cvm3gqes75f53"]
[gd_resource type="BehaviorTree" load_steps=13 format=3 uid="uid://cvm3gqes75f53"]
[sub_resource type="BBVariant" id="BBVariant_t70f2"]
resource_name = "false"
saved_value = false
type = 1
[sub_resource type="BTSetVar" id="BTSetVar_nxwdg"]
variable = "triggered"
value = SubResource("BBVariant_t70f2")
[sub_resource type="BTRunLimit" id="BTRunLimit_mlytb"]
children = [SubResource("BTSetVar_nxwdg")]
[sub_resource type="BBVariant" id="BBVariant_8bpg1"]
resource_name = "false"
saved_value = false
type = 1
[sub_resource type="BTCheckVar" id="BTCheckVar_g5b0s"]
variable = "triggered"
value = SubResource("BBVariant_8bpg1")
[sub_resource type="BBVariant" id="BBVariant_loenl"]
resource_name = "true"
saved_value = true
type = 1
[sub_resource type="BTSetVar" id="BTSetVar_u051c"]
variable = "triggered"
value = SubResource("BBVariant_loenl")
[sub_resource type="BBVariant" id="BBVariant_cu1uc"]
resource_name = "Hello, World!"
@ -14,10 +44,10 @@ text = "Message is: %s"
bb_format_parameters = PackedStringArray("message")
[sub_resource type="BTSequence" id="BTSequence_bhar3"]
children = [SubResource("BTSetVar_2e0uw"), SubResource("BTConsolePrint_533ui")]
children = [SubResource("BTCheckVar_g5b0s"), SubResource("BTSetVar_u051c"), SubResource("BTSetVar_2e0uw"), SubResource("BTConsolePrint_533ui")]
[sub_resource type="BTRunLimit" id="BTRunLimit_hv3vu"]
children = [SubResource("BTSequence_bhar3")]
[sub_resource type="BTSelector" id="BTSelector_ndrjh"]
children = [SubResource("BTRunLimit_mlytb"), SubResource("BTSequence_bhar3")]
[resource]
root_task = SubResource("BTRunLimit_hv3vu")
root_task = SubResource("BTSelector_ndrjh")