Skip to content

Adding Trinkets

AgentCucco edited this page Jan 27, 2021 · 12 revisions

Function syntax.

Encyclopedia.AddTrinket(itemTab)
  • ItemTab: 'table'. A table containing the main arguments for the trinket.

List of arguments in ItemTab:

  • Class: 'string'. The class for your trinket, usually referenced as your mod's name. (optional)
    • Note: On smaller mods, it's recommended to not add this argument, so the trinket gets added to "general mods" instead of occupying a new category in the menu.
  • ID: 'number'. Your trinket's id.
  • WikiDesc: 'table'. Your wiki table for the trinket. (optional)
  • Name: 'string'. The name of your trinket, used in case the name in the xml causes an [ERROR] tag to display in-game. (optional)
  • Desc: 'string'. The description of your trinket, used in case the description in the xml causes an [ERROR] tag to display in-game. (optional)
  • ModName: 'string'. The name of the mod attached to the trinket. (optional)
    • Mod names are already autogenerated, this argument is only used to tweak the names to others.
  • Sprite: 'sprite'. The custom sprite you want to display. (optional)
    • Note that item sprites are autogenerated by the encyclopedia, only use this argument if you want to overwrite the original.
  • Hide: 'boolean': Used in case you want to hide your trinket from the menu. (optional)
    • Trinket will still show up in the Status screen, the tag is primarily used for secret trinkets.
  • StatusFunc: 'function': Used to display a custom tooltip and change wiki entries on the fly, only during the status menu.
    • Passes (self) as an argument.
    • Runs when the status menu is opened, or the search box is used.
    • Note: You need to return a table in this function.
      • self is a copy of the original table, so you can change it without compromising the original entry.
  • StatusClose: 'function': Used to revert trinkets back to default when the menu is closed.
    • Passes (self) as an argument.
    • Runs when the status menu is closed.

How to add an trinket to the encyclopedia.

You can choose to register your trinket differently depending on how much effort you wanna put into the encyclopedia compatibility.

Just the trinket with no wiki.

local MyMod = RegisterMod("Super Mod", 1)
local FunkyTrinket = Isaac.GetTrinketIdByName("Funky Trinket")

if Encyclopedia then

Encyclopedia.AddTrinket({ID = FunkyTrinket})

end

The trinket with no wiki, but with a name tweak.

local MyMod = RegisterMod("Super Mod", 1)
local FunkyTrinket = Isaac.GetTrinketIdByName("<Funky Trinket>")

if Encyclopedia then

Encyclopedia.AddTrinket({
  ID = FunkyTrinket,
  Name = "Funky Trinket",
})

end

The trinket with a manual wiki.

local MyMod = RegisterMod("Super Mod", 1)
local FunkyTrinket = Isaac.GetTrinketIdByName("Funky Trinket")

if Encyclopedia then

local Wiki = {
  Funky = {
    { -- Effect
      {str = "Effect", fsize = 2, clr = 3, halign = 0},
      {str = "Gives you some massive funk boost."},
      {str = "If you get enough funk boost (20), summon Funky Kong."},
      {str = "+1 Funk point when you are funky."},
    },
    { -- Trivia
      {str = "Trivia", fsize = 2, clr = 3, halign = 0},
      {str = "I made this item because I honestly really like funky kong."},
    },
  }
}

Encyclopedia.AddTrinket({
  ID = FunkyTrinket,
  WikiDesc = Wiki.Funky,
})

end

The trinket with an EID wiki.

local MyMod = RegisterMod("Super Mod", 1)
local FunkyTrinket = Isaac.GetTrinketIdByName("Funky Trinket")

local FunkyDescription = "{{ArrowUp}} Gives you a lot of funk. #If you get enough funk, you will summon Funky Kong."

if EID then

EID:addTrinket(FunkyTrinket, FunkyDescription)

end

if Encyclopedia then

Encyclopedia.AddTrinket({
  ID = FunkyTrinket,
  WikiDesc = Encyclopedia.EIDtoWiki(FunkyDescrption),
})

end

If you have a big mod.

local MyMod = RegisterMod("Super Mod", 1)
local FunkyTrinket = Isaac.GetTrinketIdByName("Funky Trinket")

local FunkyDescription = "{{ArrowUp}} Gives you a lot of funk. #If you get enough funk, you will summon Funky Kong."

if Encyclopedia then

Encyclopedia.AddTrinket({
  Class = "Funky Kong Pack (25+ Trinkets)",
  ID = FunkyTrinket,
  WikiDesc = Encyclopedia.EIDtoWiki(FunkyDescrption),
})

end

If you have custom display system.

local MyMod = RegisterMod("Super Mod", 1)
local FunkyTrinket = Isaac.GetTrinketIdByName("Funky Trinket")

if Encyclopedia then

local ItemConfig = Isaac.GetItemConfig()
local ItemPool = Game():GetItemPool()

Encyclopedia.AddTrinket({
  Class = "Funky Kong Pack (25+ Trinkets)",
  ID = FunkyTrinket,
  StatusFunc = function(self)
    -- Displays a random item sprite every time the menu is updated.
    local StartSeed = Game():GetSeeds():GetStartSeed()
    local RandomColl = ItemPool:GetCollectible(math.random(1, ItemPoolType.NUM_ITEMPOOLS - 1), false, StartSeed)
    local Item = ItemConfig:GetCollectible(RandomColl)
    
    self.Spr = Encyclopedia.RegisterSprite("gfx/encyclopedia.32x32.anm2", "Idle", nil, Item.GfxFileName)

    return self
  end,
})

end

Clone this wiki locally