Fixed new method to add entity descriptions

This commit is contained in:
Wofsauge committed 2020-11-29 18:47:41 +01:00
1 parent eb3b4182a2
commit e32b32d46e
3 files changed
+11 -12

No files matched your search

+4 -5
View File
@@ -110,8 +110,6 @@ function EID:addEntity(id, variant, subtype, entityName, description, language)
subtype = subtype or nil
language = language or "en_us"
EID.descriptions[language].custom[id .. "." .. variant .. "." .. subtype] = {
id,
variant,
subtype,
entityName,
description
@@ -322,7 +320,7 @@ end
-- tries to get the ingame name of an item based on its ID
function EID:getObjectName(Type, Variant, SubType)
local tableEntry = EID:getDescriptionData(Type, Variant, SubType)
if tableEntry == nil then return "" end
if tableEntry == nil then return Type.."."..Variant.."."..SubType end
local tableName = EID:getTableName(Type, Variant)
local name = nil
if tableEntry[2] ~= nil and tableEntry[2] ~= "" then
@@ -342,9 +340,9 @@ function EID:getObjectName(Type, Variant, SubType)
elseif tableName == "dice" then
return EID:getDescriptionTable("diceHeader")
elseif tableName == "custom" then
return name or SubType
return name or Type.."."..Variant.."."..SubType
end
return ""
return Type.."."..Variant.."."..SubType
end
-- check if an entity is part of the describable entities
@@ -352,6 +350,7 @@ function EID:hasDescription(entity)
local isAllowed = false
if EID.Config["EnableEntityDescriptions"] then
isAllowed = __eidEntityDescriptions[entity.Type .. "." .. entity.Variant .. "." .. entity.SubType] ~= nil
isAllowed = isAllowed or EID:getDescriptionData(entity.Type, entity.Variant, entity.SubType) ~= nil
isAllowed = isAllowed or type(entity:GetData()["EID_Description"]) ~= type(nil)
end
isAllowed = isAllowed or (entity.Variant == PickupVariant.PICKUP_COLLECTIBLE and EID.Config["DisplayItemInfo"])
+4 -4
View File
@@ -48,7 +48,7 @@ EID:addCollectible(2, "New override Method", "new Name", "ru") -- maximal method
EID:addTrinket(2, "New override Method") -- minimal method
EID:addCard(2, "New override Method", "new Name") -- card
EID:addPill(2, "New override Method", "new Name") -- pilleffect 2 "Balls of steel"
EID:addEntity(5, 10, 2, "Custom Name", "Custom description") -- Entity
EID:addEntity(5, 10, 2, "Custom Name", "New Custom description") -- Entity
------ Test: adding custom transformation icon ------
local dummySprite = Sprite()
@@ -99,15 +99,15 @@ EID:addColor("ColorBlackBlink", nil, function(color)
local function onDebugRender(t)
for i,v in ipairs(Isaac.FindByType(5,10,2,true,false)) do
for i,v in ipairs(Isaac.FindByType(5,10,3,true,false)) do
if v:GetData()["EID_Description"] == nil then
v:GetData()["EID_Description"] = "Test specific description#Init seed: ".. v.InitSeed
end
end
for i,v in ipairs(Isaac.FindByType(5,10,3,true,false)) do
for i,v in ipairs(Isaac.FindByType(5,10,4,true,false)) do
if v:GetData()["EID_Description"] == nil then
local descTable = {
["Name"] = "Some Item with seed ".. v.InitSeed ,
--["Name"] = "Some Item with seed ".. v.InitSeed ,
["Description"] = "Test specific description#Init seed: ".. v.InitSeed,
["Transformation"] = "1,2"
}
+3 -3
View File
@@ -353,9 +353,9 @@ local function onRender(t)
local desc = closest:GetData()["EID_Description"]
local origDesc = EID:getDescriptionObj(closest.Type, closest.Variant, closest.SubType)
if type(desc) == "table" then
origDesc.Description = desc.Description
origDesc.Name = desc.Name
origDesc.Transformation = desc.Transformation
origDesc.Description = desc.Description or origDesc.Description
origDesc.Name = desc.Name or origDesc.Name
origDesc.Transformation = desc.Transformation or origDesc.Transformation
else
origDesc.Description = desc
end