From 996ae3cc9c7cab5127794a784d7ff229243ec64e Mon Sep 17 00:00:00 2001 From: Wofsauge Date: Sun, 25 Oct 2020 19:32:56 +0100 Subject: [PATCH] Readded support for custom entity descriptions --- descriptions/ab+/bul.lua | 1 + descriptions/ab+/en_us.lua | 1 + descriptions/ab+/en_us_detailed.lua | 1 + descriptions/ab+/fr.lua | 1 + descriptions/ab+/pl.lua | 1 + descriptions/ab+/pt.lua | 1 + descriptions/ab+/ru.lua | 1 + descriptions/ab+/spa.lua | 1 + eid_api.lua | 11 ++++++----- eid_debugging.lua | 4 ++-- main.lua | 19 ++++++++++--------- 11 files changed, 26 insertions(+), 16 deletions(-) diff --git a/descriptions/ab+/bul.lua b/descriptions/ab+/bul.lua index 1be5d5ad..e7d79dbd 100644 --- a/descriptions/ab+/bul.lua +++ b/descriptions/ab+/bul.lua @@ -13,6 +13,7 @@ -- init bul table EID.descriptions["bul"] = {} +EID.descriptions["bul"].custom = {} -- table for custom entity descriptions EID.descriptions["bul"].collectibles={ {"1", "0", "Òúæíèÿò ëóê", "\1 0.7 Ñêîðîñò íà ñúëçèòå"}, diff --git a/descriptions/ab+/en_us.lua b/descriptions/ab+/en_us.lua index c7a4b8c9..4930ce12 100644 --- a/descriptions/ab+/en_us.lua +++ b/descriptions/ab+/en_us.lua @@ -13,6 +13,7 @@ -- init en_us table EID.descriptions["en_us"] = {} +EID.descriptions["en_us"].custom = {} -- table for custom entity descriptions EID.descriptions["en_us"].collectibles={{"1", "0", "", "↑ +0.7 Tears up"}, {"2", "0", "", "Triple shot#↓ Tears down"}, diff --git a/descriptions/ab+/en_us_detailed.lua b/descriptions/ab+/en_us_detailed.lua index caf89fcd..94bfe7b8 100644 --- a/descriptions/ab+/en_us_detailed.lua +++ b/descriptions/ab+/en_us_detailed.lua @@ -10,6 +10,7 @@ -- init en_us_detailed table EID.descriptions["en_us_detailed"] = {} +EID.descriptions["en_us_detailed"].custom = {} -- table for custom entity descriptions EID.descriptions["en_us_detailed"].collectibles={ {"1", "0", "", "+0.7 Tears up."}, diff --git a/descriptions/ab+/fr.lua b/descriptions/ab+/fr.lua index 7ef35323..5ac19c8a 100644 --- a/descriptions/ab+/fr.lua +++ b/descriptions/ab+/fr.lua @@ -17,6 +17,7 @@ -- init fr table EID.descriptions["fr"] = {} +EID.descriptions["fr"].custom = {} -- table for custom entity descriptions EID.descriptions["fr"].collectibles={ {"1", "0", "", "↑ +0.7 Cadence de tir"}, diff --git a/descriptions/ab+/pl.lua b/descriptions/ab+/pl.lua index 4d4305c6..b83a3130 100644 --- a/descriptions/ab+/pl.lua +++ b/descriptions/ab+/pl.lua @@ -20,6 +20,7 @@ -- init pl table EID.descriptions["pl"] = {} +EID.descriptions["pl"].custom = {} -- table for custom entity descriptions EID.descriptions["pl"].collectibles={{"1","0","\1 +0.7 Szybkostrzelno¶ci"}, {"2","0","Potrójne strza³y#\2 Mniejsza Szybkostrzelno¶æ"}, diff --git a/descriptions/ab+/pt.lua b/descriptions/ab+/pt.lua index ce745bfe..f927730d 100644 --- a/descriptions/ab+/pt.lua +++ b/descriptions/ab+/pt.lua @@ -16,6 +16,7 @@ -- init pt table EID.descriptions["pt"] = {} +EID.descriptions["pt"].custom = {} -- table for custom entity descriptions EID.descriptions["pt"].collectibles={ {"1", "0", "", "↑ +0.7 lágrimas up"}, diff --git a/descriptions/ab+/ru.lua b/descriptions/ab+/ru.lua index d567c1ed..fd55ae8e 100644 --- a/descriptions/ab+/ru.lua +++ b/descriptions/ab+/ru.lua @@ -1,6 +1,7 @@ -- init ru table EID.descriptions["ru"] = {} +EID.descriptions["ru"].custom = {} -- table for custom entity descriptions EID.descriptions["ru"].collectibles={ {"1", "0", "ГруÑ�тный Лук", "\1 0.7 к Ñ�короÑ�трельноÑ�ти"}, diff --git a/descriptions/ab+/spa.lua b/descriptions/ab+/spa.lua index 947554ff..81240198 100644 --- a/descriptions/ab+/spa.lua +++ b/descriptions/ab+/spa.lua @@ -16,6 +16,7 @@ -- init spa table EID.descriptions["spa"] = {} +EID.descriptions["spa"].custom = {} -- table for custom entity descriptions EID.descriptions["spa"].collectibles={ {"1", "0", "", "↑ +0,7 de lágrimas"}, diff --git a/eid_api.lua b/eid_api.lua index 22ad583d..161ccd7c 100644 --- a/eid_api.lua +++ b/eid_api.lua @@ -110,7 +110,7 @@ function EID:getLegacyModDescription(objTable, id) elseif objTable == "transformation" then return (__eidItemTransformations) and (__eidItemTransformations[id]) elseif objTable == "custom" then - return (__eidEntityDescriptions) and (__eidEntityDescriptions[id]) + return (__eidEntityDescriptions) and (__eidEntityDescriptions[id][2]) end end @@ -123,10 +123,11 @@ end -- returns the description object of the specified object table translated with the current language -- falls back to english if the objID isnt available function EID:getDescriptionObj(objTable, objID) - local tableEntry = EID.descriptions[EIDConfig["Language"]][objTable][tonumber(objID)] or EID.descriptions["en_us"][objTable][tonumber(objID)] + local tableEntry = EID.descriptions[EIDConfig["Language"]][objTable][objID] or EID.descriptions["en_us"][objTable][objID] or {} local description = {} - description.ID = tonumber(tableEntry[1]) or objID + description.ID = objID + description.Name = EID:getObjectName(objID, objTable) or objTable local legacyModdedDescription = EID:getLegacyModDescription(objTable, objID) @@ -152,7 +153,7 @@ end -- tries to get the ingame name of an item based on its ID function EID:getObjectName(objID, objType) - local tableEntry = EID.descriptions[EIDConfig["Language"]][objType][tonumber(objID)] or EID.descriptions["en_us"][objType][tonumber(objID)] + local tableEntry = EID.descriptions[EIDConfig["Language"]][objType][objID] or EID.descriptions["en_us"][objType][objID] if objType == "collectibles" then if EIDConfig["Language"]~="en_us" and #tableEntry==4 then if tableEntry[3] ~= nil and tableEntry[3] ~= "" then @@ -186,7 +187,7 @@ function EID:getObjectName(objID, objType) elseif objType == "dice" then return EID:getDescriptionTable("diceHeader") elseif objType == "custom" then - return objID + return __eidEntityDescriptions[objID][1] or tableEntry[1] or objID end end diff --git a/eid_debugging.lua b/eid_debugging.lua index 7bd3bd60..c90a6625 100644 --- a/eid_debugging.lua +++ b/eid_debugging.lua @@ -25,9 +25,9 @@ __eidItemDescriptions[1] = "\1 Overriden description" -- 5.100.1 = Sad Onion __eidTrinketDescriptions[1] = "\2 Overriden " -- 5.350.1 = swallowed penny __eidCardDescriptions[1] = "Overriden Card description" -- 5.300.1 = the fool __eidPillDescriptions[21] = "Test" -- Pill Effect 20 = Hematemesis +__eidItemTransformations[1] = "Test Transformation" -- add custom transformation Text to Sad Onion --- Legacy add Description -__eidItemTransformations[1] = "Test Transformation" +-- Legacy add Description to entity __eidEntityDescriptions["5.10.1"] = {"Entity Name","Entity description"} -- Adds description to full red hearts -- test adding custom icons diff --git a/main.lua b/main.lua index 5aa3cd11..b469bcbc 100644 --- a/main.lua +++ b/main.lua @@ -84,8 +84,10 @@ end function printDescription(desc) local padding = posY() - local itemType = EID.itemConfig:GetCollectible(desc.ID).Type - + local itemType = -1 + if tonumber(desc.ID)~=nil then + itemType = EID.itemConfig:GetCollectible(tonumber(desc.ID)).Type or -1 + end --Display ItemType / Charge if EIDConfig["ShowItemType"] and (itemType == 3 or itemType == 4) then local offsetY = 2 * EIDConfig["Scale"] @@ -319,25 +321,24 @@ local function onRender(t) printTrinketDescription({closest.Type, closest:GetData()["EID_Description"]}, "custom") return end - + ]]-- --Handle Entities (omni) - if EIDConfig["EnableEntityDescriptions"] and - __eidEntityDescriptions[closest.Type .. "." .. closest.Variant .. "." .. closest.SubType] ~= nil - then + if EIDConfig["EnableEntityDescriptions"] then printDescription(EID:getDescriptionObj("custom", closest.Type .. "." .. closest.Variant .. "." .. closest.SubType)) return - end]]-- + end + --Handle Trinkets if closest.Variant == PickupVariant.PICKUP_TRINKET then - printDescription(EID:getDescriptionObj("trinkets",closest.SubType)) + printDescription(EID:getDescriptionObj("trinkets", closest.SubType)) --Handle Collectibles elseif closest.Variant == PickupVariant.PICKUP_COLLECTIBLE then if EID:hasCurseBlind() and EIDConfig["DisableOnCurse"] then renderQuestionMark() return end - printDescription(EID:getDescriptionObj("collectibles",closest.SubType)) + printDescription(EID:getDescriptionObj("collectibles", closest.SubType)) --Handle Cards & Runes elseif closest.Variant == PickupVariant.PICKUP_TAROTCARD then if closest:ToPickup():IsShopItem() and not EIDConfig["DisplayCardInfoShop"] then