From e415b1be794e2a3b87c54287ec039615bb2d2227 Mon Sep 17 00:00:00 2001 From: ANAND Date: Sat, 25 Apr 2020 00:46:35 +0530 Subject: [PATCH] ctf_markers: Fix occasional crash due to invalid ObjectRef --- mods/ctf/ctf_marker/init.lua | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/mods/ctf/ctf_marker/init.lua b/mods/ctf/ctf_marker/init.lua index 58b5053..36e2eb2 100644 --- a/mods/ctf/ctf_marker/init.lua +++ b/mods/ctf/ctf_marker/init.lua @@ -99,15 +99,18 @@ minetest.register_chatcommand("m", { if pointed.type == "object" then local concat local obj = pointed.ref + local entity = obj:get_luaentity() + + -- If object is a player, append player name to display text + -- Else if obj is item entity, append item description and count to str. if obj:is_player() then concat = obj:get_player_name() - else - local entity = obj:get_luaentity() - -- If obj is item entity, append item description and count to str. - -- Fallback to itemstring if description doesn't exist + elseif entity then if entity.name == "__builtin:item" then local stack = ItemStack(entity.itemstring) local itemdef = minetest.registered_items[stack:get_name()] + + -- Fallback to itemstring if description doesn't exist concat = itemdef.description or entity.itemstring concat = concat .. " " .. stack:get_count() else