Add guaranteed non-nil name for itemstack
This commit is contained in:
parent
f70ad73ac0
commit
d16558853c
@ -112,6 +112,30 @@ function ItemStack:getDisplayName()
|
||||
return self.displayName
|
||||
end
|
||||
|
||||
function ItemStack:getSimpleName()
|
||||
local displayName = self:getDisplayName()
|
||||
if displayName ~= nil then
|
||||
return displayName
|
||||
end
|
||||
|
||||
local name = self:getName()
|
||||
if name ~= nil then
|
||||
local _, e = name:find(":")
|
||||
if e == nil then
|
||||
return name
|
||||
end
|
||||
|
||||
local simpleName = name:sub(e + 1)
|
||||
if #simpleName == 0 then
|
||||
return name
|
||||
end
|
||||
|
||||
return simpleName
|
||||
end
|
||||
|
||||
return self:getInventory():getName().."["..self:getSlot().."]"
|
||||
end
|
||||
|
||||
function ItemStack:hasChanged(listObj, thorough)
|
||||
local listItem = listObj[self.slot]
|
||||
if listItem == nil or listItem.name ~= self.name or listItem.count ~= self.count then
|
||||
|
Loading…
x
Reference in New Issue
Block a user