From 11304542bdb10e019ee376f1d222f1876c9a0ddb Mon Sep 17 00:00:00 2001 From: zhexu14 <64713351+zhexu14@users.noreply.github.com> Date: Sat, 25 May 2024 15:09:18 +1000 Subject: [PATCH] Wrap getLife with pcall to handle error where unit is lost (#3390) --- resources/plugins/base/dcs_liberation.lua | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/resources/plugins/base/dcs_liberation.lua b/resources/plugins/base/dcs_liberation.lua index f94771c3..2f5597ce 100644 --- a/resources/plugins/base/dcs_liberation.lua +++ b/resources/plugins/base/dcs_liberation.lua @@ -151,9 +151,11 @@ end function update_hit_points(event) local update = {} update.name = event.target:getName() - update.hit_points = event.target:getLife() - unit_hit_point_updates[#unit_hit_point_updates + 1] = update - write_state() + get_life_success, update.hit_points = pcall(event.target.getLife, event.target) + if get_life_success then + unit_hit_point_updates[#unit_hit_point_updates + 1] = update + write_state() + end end activeWeapons = {}