From 150ea379c8b7802f3fd4de5d84f05caee98cc1bd Mon Sep 17 00:00:00 2001 From: Bo Chen Date: Tue, 13 Feb 2024 13:11:12 +0100 Subject: [PATCH] Add support to concat strings and numbers in scripting. Solves #766 --- include/behaviortree_cpp/scripting/operators.hpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/include/behaviortree_cpp/scripting/operators.hpp b/include/behaviortree_cpp/scripting/operators.hpp index 3b1f323f7..2aed0fb06 100644 --- a/include/behaviortree_cpp/scripting/operators.hpp +++ b/include/behaviortree_cpp/scripting/operators.hpp @@ -252,7 +252,9 @@ struct ExprBinaryArithmetic : ExprBase } } } - else if (rhs_v.isString() && lhs_v.isString() && op == plus) + else if (op == plus && ((rhs_v.isString() && lhs_v.isString()) || + (rhs_v.isString() && lhs_v.isNumber()) || + (rhs_v.isNumber() && lhs_v.isString()))) { return Any(lhs_v.cast() + rhs_v.cast()); }