From 03de61f2b76fc814dfcdf56b97b432dc964ebaac 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 f386ff026..b52befbfa 100644 --- a/mods/ctf/ctf_marker/init.lua +++ b/mods/ctf/ctf_marker/init.lua @@ -96,15 +96,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