Compare commits

...
13 Commits
6 changed files with 106 additions and 41 deletions

No files matched your search

+78 -1
View File
@@ -43,6 +43,36 @@ function EID:addTrinket(id, description, itemName, language)
EID.descriptions[language].custom["5.350." .. id] = {id, itemName, description, EID._currentMod}
end
-- Adds information about appending text and multiplying numbers in a modded trinket's Golden/Mom's Box description. All three variables are optional, set to ""/0 or nil to not include them
-- appendText can be 1 string, or a table of 2 strings; one for doubling and one for tripling
-- numbersToMultiply can be 1 number, or a table of numbers
-- maxMultiplier is what tripling (Golden+Mom's Box) should multiply the numbers by (normally 3)
-- (If it's less than 2, it also applies to doubling)
-- Example: My modded trinket gives +0.5 range, and when tripled, adds homing instead of tripling the range boost
-- EID:addGoldenTrinketMetadata(Isaac.GetTrinketIdByName("Cool Trinket"), {"", "Homing tears"}, 0.5, 2)
function EID:addGoldenTrinketMetadata(id, appendText, numbersToMultiply, maxMultiplier, language)
maxMultiplier = maxMultiplier or 3
language = language or "en_us"
if appendText == "" then appendText = nil
elseif type(appendText) == "string" then appendText = {appendText} end
if numbersToMultiply == 0 then numbersToMultiply = nil
elseif type(numbersToMultiply) == "number" then numbersToMultiply = {numbersToMultiply} end
EID.GoldenTrinketData[id] = {t = numbersToMultiply, mult = maxMultiplier, append = appendText and true}
if appendText then
EID.descriptions[language].goldenTrinketEffects[id] = { appendText[1], appendText[1], appendText[2] or appendText[1] }
end
end
-- Add a fully custom data table to the table of Golden Trinket effects
-- Check the comments above EID.GoldenTrinketData in eid_data.lua for some info about what is possible
-- You may also want to add text entries into EID.descriptions[languageCode].goldenTrinketEffects
function EID:addGoldenTrinketTable(id, dataTable)
EID.GoldenTrinketData[id] = dataTable
end
-- Adds a description for a card/rune. Optional parameters: itemName, language
function EID:addCard(id, description, itemName, language)
itemName = itemName or nil
@@ -320,6 +350,8 @@ function EID:getDescriptionObj(Type, Variant, SubType, entity, checkModifiers)
description.Transformation = EID:getTransformation(Type, Variant, SubType)
description.ModName = tableEntry and tableEntry[4]
description.Quality = EID:getObjectQuality(description)
description.Icon = EID:getObjectIcon(description)
if checkModifiers ~= false then
for _,modifier in ipairs(EID.DescModifiers) do
@@ -690,7 +722,7 @@ end
-- Returns the icon used for the bulletpoint. It will look at the first word in the given string.
-- Also returns the first word if it was rejected (so it can be removed from the line)
function EID:handleBulletpointIcon(text)
local firstWord = string.match(text, "([^%s]+)")
local firstWord = EID:removeColorMarkup(string.match(text, "([^%s]+)"))
if EID:getIcon(firstWord) ~= EID.InlineIcons["ERROR"] and string.find(firstWord, "{{.-}}")~=nil then
if not EID.Config["StatAndPickupBulletpoints"] and EID.StatPickupBulletpointBlacklist[firstWord] then
return "\007", firstWord
@@ -750,6 +782,14 @@ function EID:filterColorMarkup(text, baseKColor)
return textPartsTable
end
-- A simple function to remove color markup, to preserve bulletpoint icons after start-of-line color markup
function EID:removeColorMarkup(text)
for word in string.gmatch(text, "{{Color.-}}") do
text = string.gsub(text, word, "", 1)
end
return text
end
-- A simple function to replace all markup {{ }} with placeholder strings, to use in fitTextToWidth
function EID:replaceAllMarkupWithSpaces(text, checkBulletpoint)
if checkBulletpoint then
@@ -1528,3 +1568,40 @@ function EID:evaluateQueuedItems()
end
end
end
-- Returns the quality of the described entity
function EID:getObjectQuality(descObj)
if REPENTANCE and descObj.ObjType == 5 and descObj.ObjVariant == 100 then
return tonumber(EID.itemConfig:GetCollectible(tonumber(descObj.ObjSubType)).Quality)
end
end
-- Returns the Inline Icon definition object for a given object.
EID.ObjectIcon = {}
function EID:getObjectIcon(descObj)
-- custom object icon
if EID.ObjectIcon[descObj.ObjType.."."..descObj.ObjVariant.."."..descObj.ObjSubType] then
return EID.ObjectIcon[descObj.ObjType.."."..descObj.ObjVariant.."."..descObj.ObjSubType]
end
if descObj.ObjType == 5 then
if descObj.ObjVariant == 100 then
return EID:createItemIconObject("Collectible" .. descObj.ObjSubType)
elseif descObj.ObjVariant == 350 then
return EID:createItemIconObject("Trinket" .. descObj.ObjSubType)
elseif descObj.ObjVariant == 300 then
return EID:createItemIconObject("Card" .. descObj.ObjSubType)
elseif descObj.ObjVariant == 70 then
if descObj.ObjSubType >= 2049 then
return EID:createItemIconObject("Pill" .. (descObj.ObjSubType - 2048))
end
return EID:createItemIconObject("Pill" .. descObj.ObjSubType)
end
end
end
-- Adds an EID Icon to an Object
function EID:AddIconToObject(eType, eVariant, eSubType, iconName)
EID.ObjectIcon[eType.."."..eVariant.."."..eSubType] = EID.InlineIcons[iconName]
end
+7 -3
View File
@@ -789,6 +789,7 @@ local newResults = {}
local skipRandom = false
local isRefresh = false
local queryString = ""
local displayingRecipeList = false
local function RecipeCrunchCoroutine()
coTimer = Isaac.GetTime()
@@ -894,7 +895,7 @@ function EID:handleBagOfCraftingUpdating()
end
-- Check for Hold Tab key inputs
if Input.IsActionPressed(EID.Config["BagOfCraftingToggleKey"], EID.bagPlayer.ControllerIndex) then
if displayingRecipeList and Input.IsActionPressed(EID.Config["BagOfCraftingToggleKey"], EID.bagPlayer.ControllerIndex) then
EID.bagPlayer.ControlsCooldown = 2
if Input.IsActionTriggered(ButtonAction.ACTION_SHOOTDOWN, EID.bagPlayer.ControllerIndex) then
bagOfCraftingOffset = math.min(numResults-(numResults%EID.Config["BagOfCraftingResults"]), bagOfCraftingOffset + EID.Config["BagOfCraftingResults"])
@@ -940,9 +941,11 @@ end
-- Called when needed based on EID.Config["RefreshRate"]
function EID:handleBagOfCraftingRendering(ignoreRefreshRate)
-- Determine if we should display anything at all
if ((EID.isHidden or craftingIsHidden) and EID.MCMCompat_isDisplayingEIDTab ~= "Crafting") or game.Challenge == Challenge.CHALLENGE_CANTRIPPED then
if not EID:RefreshThisFrame() and not ignoreRefreshRate then
return false
elseif not EID:RefreshThisFrame() and not ignoreRefreshRate then
end
displayingRecipeList = false
if ((EID.isHidden or craftingIsHidden) and EID.MCMCompat_isDisplayingEIDTab ~= "Crafting") or game.Challenge == Challenge.CHALLENGE_CANTRIPPED then
return false
elseif EID.Config["BagOfCraftingHideInBattle"] then
if Isaac.CountBosses() > 0 or Isaac.CountEnemies() > 0 then
@@ -1070,6 +1073,7 @@ function EID:handleBagOfCraftingRendering(ignoreRefreshRate)
end
-- Recipe List display
displayingRecipeList = true
if sortNeeded then
sortAllItems()
sortNeeded = false
+1
View File
@@ -125,6 +125,7 @@ local dummySprite2 = Sprite()
dummySprite2:Load("gfx/eid_inline_icons.anm2", true)
-- add animated icon using api function (Make sure to create new Sprite Obj when using animated icons. Reuse objects when only using static icons)
EID:addIcon("TestIcon", "hearts", -1, 9, 9, -1, 0, dummySprite2)
EID:AddIconToObject(5, 100, 1, "TestIcon")
-- add icon directly
+8 -3
View File
@@ -373,23 +373,28 @@ if REPENTANCE then
end
end)
end
end
--replacing a phrase, such as "half a heart"
elseif data.findReplace then
if data.findReplace then
local textTable = EID:getDescriptionEntry("goldenTrinketEffects", trinketID)
if textTable then
descObj.Description, count = string.gsub(descObj.Description, textTable[1], "{{ColorGold}}" .. textTable[multiplier] .. "{{ColorText}}", 1)
end
end
--append some new text to the description
elseif data.append then
if data.append then
local textTable = EID:getDescriptionEntry("goldenTrinketEffects", trinketID)
if textTable then
textChoice = math.min(textChoice, #textTable) -- some items have only 1 append description
if textTable[textChoice] ~= "" then
descObj.Description = descObj.Description .. "#{{ColorGold}}" .. textTable[textChoice]
count = 1
end
end
end
--the nuclear option: replacing the entire description; 1 = Gold, 2 = Mom's Box, 3 = Both
--only replace if the chosen language has defined it
elseif data.fullReplace then
if data.fullReplace then
local textTable = EID:getDescriptionEntry("goldenTrinketEffects", trinketID, true)
if (textTable) then
textChoice = math.min(textChoice, #textTable)
+11 -33
View File
@@ -9,7 +9,7 @@ local game = Game()
require("eid_config")
EID.Config = EID.UserConfig
EID.Config.Version = "3.2" -- note: changing this will reset everyone's settings to default!
EID.ModVersion = "4.26"
EID.ModVersion = "4.27"
EID.DefaultConfig.Version = EID.Config.Version
EID.isHidden = false
EID.player = nil -- The primary Player Entity of Player 1
@@ -477,7 +477,8 @@ function EID:printDescriptions(useCached)
-- Do the description entities match, and the description texts match?
for i,newDesc in ipairs(EID.descriptionsToPrint) do
local oldDesc = EID.previousDescs[i]
if newDesc.Description ~= oldDesc.Description or (newDesc.Entity and oldDesc.Entity and GetPtrHash(newDesc.Entity) ~= GetPtrHash(oldDesc.Entity)) then
if newDesc.Description ~= oldDesc.Description or newDesc.Name ~= oldDesc.Name or
(newDesc.Entity and oldDesc.Entity and GetPtrHash(newDesc.Entity) ~= GetPtrHash(oldDesc.Entity)) then
EID:printNewDescriptions()
return
end
@@ -522,7 +523,6 @@ function EID:printDescription(desc, cachedID)
end
local renderPos = EID:getTextPosition()
--print(cachedID)
if cachedID then
local localModeDiff = renderPos - EID.CachedRenderPoses[cachedID]
-- Drawing our currently saved description
@@ -556,33 +556,11 @@ function EID:printDescription(desc, cachedID)
local textScale = Vector(EID.Scale, EID.Scale)
local offsetX = 0
EID.lineHeight = EID.Config["LineHeight"]
if EID.Config["ShowItemIcon"] then
local iconType = nil
local subType = desc.ObjSubType
if desc.ObjType == 5 then
if desc.ObjVariant == 100 then
iconType = "Collectible"
elseif desc.ObjVariant == 350 then
iconType = "Trinket"
elseif desc.ObjVariant == 300 then
iconType = "Card"
elseif desc.ObjVariant == 70 then
iconType = "Pill"
if subType >= 2049 then
subType = subType - 2048
end
end
end
if iconType ~= nil then
if EID.Config["ShowItemIcon"] and desc.Icon then
offsetX = offsetX + 14
EID:renderString(
"{{" .. iconType .. subType .. "}}",
renderPos + (Vector(-3, -4) * EID.Scale),
textScale,
EID:getNameColor()
)
end
EID:renderInlineIcons({{desc.Icon,0}}, renderPos.X - 3 * EID.Scale, renderPos.Y - 4 * EID.Scale)
end
--Display ItemType / Charge
local itemType = -1
if desc.ObjSubType ~= nil and desc.ObjType == 5 and desc.ObjVariant == 100 then
@@ -632,9 +610,8 @@ function EID:printDescription(desc, cachedID)
curName = curName.." {{ColorGray}}"..desc.ObjType.."."..desc.ObjVariant.."."..desc.ObjSubType
end
-- Display Quality
if REPENTANCE and EID.Config["ShowQuality"] and desc.ObjVariant == PickupVariant.PICKUP_COLLECTIBLE then
local quality = tonumber(EID.itemConfig:GetCollectible(tonumber(desc.ObjSubType)).Quality)
curName = curName.." - {{Quality"..quality.."}}"
if EID.Config["ShowQuality"] and desc.Quality then
curName = curName.." - {{Quality"..desc.Quality.."}}"
end
-- Display the mod this item is from
if desc.ModName then
@@ -1062,8 +1039,9 @@ local function attemptPathfind(entity)
if pathsChecked[entity.InitSeed] == false and EID.GameUpdateCount - lastPathfindFrame < 10 then return false end
-- Spawn a Shopkeeper entity to attempt a pathfind to the target pickup, then remove it afterwards
pathCheckerEntity = game:Spawn(17, 0, EID.player.Position, nullVector, EID.player, 0, 4354)
pathCheckerEntity = game:Spawn(17, 0, EID.player.Position, nullVector, EID.player, 6969, 4354)
pathCheckerEntity:GetData()["EID_Pathfinder"] = true
pathCheckerEntity.Visible = false
local success = pathCheckerEntity:ToNPC().Pathfinder:HasPathToPos(entity.Position, false)
pathsChecked[entity.InitSeed] = success
pathCheckerEntity:Remove()
+1 -1
View File
@@ -113,7 +113,7 @@ https://moddingofisaac.com/mod/1079/external-item-descriptions
- prefab for the incredible [b]Japanese[/b] language pack
- domcizzz for the cool [b]Czech[/b] language pack
- [url=https://steamcommunity.com/id/whytefang/]adc[/url] for creating an awesome new Languagepack and providing ideas for new functionalities</description>
<version>4.26</version>
<version>4.27</version>
<visibility>Public</visibility>
<tag id="Lua"/>
<tag id="Items"/>