ctf_markers: Fix occasional crash due to invalid ObjectRef
This commit is contained in:
parent
dc72f1d10e
commit
e415b1be79
1 changed files with 7 additions and 4 deletions
|
@ -99,15 +99,18 @@ minetest.register_chatcommand("m", {
|
||||||
if pointed.type == "object" then
|
if pointed.type == "object" then
|
||||||
local concat
|
local concat
|
||||||
local obj = pointed.ref
|
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
|
if obj:is_player() then
|
||||||
concat = obj:get_player_name()
|
concat = obj:get_player_name()
|
||||||
else
|
elseif entity then
|
||||||
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
|
|
||||||
if entity.name == "__builtin:item" then
|
if entity.name == "__builtin:item" then
|
||||||
local stack = ItemStack(entity.itemstring)
|
local stack = ItemStack(entity.itemstring)
|
||||||
local itemdef = minetest.registered_items[stack:get_name()]
|
local itemdef = minetest.registered_items[stack:get_name()]
|
||||||
|
|
||||||
|
-- Fallback to itemstring if description doesn't exist
|
||||||
concat = itemdef.description or entity.itemstring
|
concat = itemdef.description or entity.itemstring
|
||||||
concat = concat .. " " .. stack:get_count()
|
concat = concat .. " " .. stack:get_count()
|
||||||
else
|
else
|
||||||
|
|
Loading…
Reference in a new issue