From 6d705581396ac4d26fc3b8760fda230b8df74923 Mon Sep 17 00:00:00 2001 From: dong50252409 <304887750@qq.com> Date: Wed, 11 May 2022 17:36:14 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8A=A0=E8=BD=BD=E8=A1=8C=E4=B8=BA=E6=A0=91?= =?UTF-8?q?=E6=96=87=E4=BB=B6=E6=97=B6=EF=BC=8C=E8=BD=BD=E5=85=A5=E8=A1=8C?= =?UTF-8?q?=E4=B8=BA=E6=A0=91=E6=A8=A1=E5=9D=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/core/behavior_tree.erl | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/core/behavior_tree.erl b/src/core/behavior_tree.erl index cb8b50d..cbd1cfe 100644 --- a/src/core/behavior_tree.erl +++ b/src/core/behavior_tree.erl @@ -166,8 +166,13 @@ load_beam_code(JSONConfig, TreeNodes, Titles, Options) -> Body2 = [ [ - io_lib:format("get_node(~w) -> ~w;\n", [ID, TreeNode]) - || #tree_node{id = ID} = TreeNode <- TreeNodes + case code:ensure_loaded(Name) of + {module, _} -> + io_lib:format("get_node(~w) -> ~w;\n", [ID, TreeNode]); + {error, What} -> + error({node_not_implement, Name, What}) + end + || #tree_node{id = ID, name = Name} = TreeNode <- TreeNodes ], "get_node(_) -> erlang:throw(node_not_exist).\n\n" ],