From b60439bddcce3af0a7691bc8bade6cb4eaabcf13 Mon Sep 17 00:00:00 2001 From: Wofsauge Date: Wed, 31 Aug 2022 22:55:13 +0200 Subject: [PATCH] Added Name-Markup. Example: {{NameC3}} -> Spoon Bender --- eid_api.lua | 27 +++++++++++++++++++++++++++ eid_debugging.lua | 2 +- main.lua | 1 + 3 files changed, 29 insertions(+), 1 deletion(-) diff --git a/eid_api.lua b/eid_api.lua index 0f87aa25..68182ec8 100644 --- a/eid_api.lua +++ b/eid_api.lua @@ -627,6 +627,33 @@ function EID:replaceShortMarkupStrings(text) return text end +-- Replaces name markup objects with the actual name +function EID:replaceNameMarkupStrings(text) + for word in string.gmatch(text, "{{Name.-}}") do + local strTrimmed = string.gsub(word, "{{Name(.-)}}", function(a) return a end) + local indicator = string.sub(strTrimmed, 1, 1) + local id = tonumber(string.sub(strTrimmed, 2, -1)) + local name = "" + if tonumber(indicator) then + local entityID = {} + for e in string.gmatch(strTrimmed, "([^.]*)") do + table.insert(entityID, tonumber(e)) + end + name = EID:getObjectName(entityID[1], entityID[2], entityID[3]) + elseif indicator == "C" then -- Collectible + name = EID:getObjectName(5, 100, id) + elseif indicator == "T" then -- Trinket + name = EID:getObjectName(5, 350, id) + elseif indicator == "P" then -- Pills + name = EID:getObjectName(5, 70, id) + elseif indicator == "K" then -- Card + name = EID:getObjectName(5, 300, id) + end + text = string.gsub(text, word, name, 1) + end + return text +end + -- Generates a string with the defined pixel-length using a custom 1px wide character -- This will only work for this specific custom font function EID:generatePlaceholderString(length) diff --git a/eid_debugging.lua b/eid_debugging.lua index 5616a9eb..5cdb4545 100644 --- a/eid_debugging.lua +++ b/eid_debugging.lua @@ -161,7 +161,7 @@ EID.InlineIcons["Test"] = {"pickups", -1, 9, 9, -1, 0, dummySprite3} __eidItemDescriptions[3] = "{{Bomb}} Emote {{Key}} Test {{Test}}{{TestIcon}} {{ColorBlackBlink}}description {{SomeInvalidInnerStuff}} cool" -- 5.100.2 = Inner Eye -__eidItemDescriptions[6] = "This item as Inline Icon {{Collectible6}}#And here are others {{Collectible69}} {{Collectible16}} {{Collectible323}} {{Collectible345}} {{Collectible223}}#And some trinket sprites {{Trinket12}} {{Trinket22}} {{Trinket1}} {{Trinket55}} {{Trinket100}} {{Trinket123}}" -- 5.100.2 = Inner Eye +__eidItemDescriptions[6] = "This item as Inline Icon {{Collectible6}}#And here are others {{Collectible69}} {{Collectible16}} {{Collectible323}} {{Collectible345}} {{Collectible223}}#And some trinket sprites {{Trinket12}} {{Trinket22}} {{Trinket1}} {{Trinket55}} {{Trinket100}} {{Trinket123}}#And some names {{NameC3}} {{NameT23}} {{Name5.100.231}}" -- 5.100.2 = Inner Eye EID:addIgnoredEntity(5,100,10) -- Ignore "Halo of flies" collectible entity diff --git a/main.lua b/main.lua index 9d2756fe..b9f1d5dd 100644 --- a/main.lua +++ b/main.lua @@ -711,6 +711,7 @@ end function EID:printBulletPoints(description, renderPos) local textboxWidth = tonumber(EID.Config["TextboxWidth"]) local textScale = Vector(EID.Scale, EID.Scale) + description = EID:replaceNameMarkupStrings(description) description = EID:replaceShortMarkupStrings(description) description = EID:replaceMarkupSize(description) for line in string.gmatch(description, "([^#]+)") do