Skip to content

Adding Items

AgentCucco edited this page Jan 27, 2021 · 15 revisions

Function syntax.

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

List of arguments in ItemTab:

  • Class: 'string'. The class for your item, usually referenced as your mod's name. (optional)
    • Note: On smaller mods, it's recommended to not add this argument, so the item gets added to "general mods" instead of occupying a new category in the menu.
  • ID: 'number'. Your item's id.
  • WikiDesc: 'table'. Your wiki table for the item. (optional)
  • Pools: 'table': A table of pools. (optional)
  • Name: 'string'. The name of your item, used in case the name in the xml causes an [ERROR] tag to display in-game. (optional)
  • Desc: 'string'. The description of your item, used in case the description in the xml causes an [ERROR] tag to display in-game. (optional)
  • Hide: 'boolean': Used in case you want to hide your item from the menu. (optional)
    • Item will still show up in the Status screen, the tag is primarily used for secret items.
  • StatusFunc: 'function': Used to display a custom tooltip and change wiki entries on the fly, only during the status menu. (optional)
    • 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 items back to default when the menu is closed. (optional)
    • Passes (self) as an argument.
    • Runs when the status menu is closed.

How to add an item to the encyclopedia.

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

Just the item with no wiki.

local MyMod = RegisterMod("Super Mod", 1)
local FunkyItem = Isaac.GetItemIdByName("Funky Item")

if Encyclopedia then

Encyclopedia.AddItem({
  ID = FunkyItem,
  Pools = {
    Encyclopedia.ItemPools.POOL_TREASURE,
    Encyclopedia.ItemPools.POOL_GREED_TREASURE,
  },
})

end

The item with no wiki or pools, but with a name tweak.

local MyMod = RegisterMod("Super Mod", 1)
local FunkyItem = Isaac.GetItemIdByName("<Funky Item>")

if Encyclopedia then

Encyclopedia.AddItem({
  ID = FunkyItem,
  Name = "Funky Item",
})

end

The item with a manual wiki.

local MyMod = RegisterMod("Super Mod", 1)
local FunkyItem = Isaac.GetItemIdByName("Funky Item")

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.AddItem({
  ID = FunkyItem,
  WikiDesc = Wiki.Funky,
  Pools = {
    Encyclopedia.ItemPools.POOL_TREASURE,
    Encyclopedia.ItemPools.POOL_GREED_TREASURE,
  },
})

end

The item with an EID wiki.

local MyMod = RegisterMod("Super Mod", 1)
local FunkyItem = Isaac.GetItemIdByName("Funky Item")

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

if EID then

EID:addCollectible(FunkyItem, FunkyDescription)

end

if Encyclopedia then

Encyclopedia.AddItem({
  ID = FunkyItem,
  WikiDesc = Encyclopedia.EIDtoWiki(FunkyDescrption),
  Pools = {
    Encyclopedia.ItemPools.POOL_TREASURE,
    Encyclopedia.ItemPools.POOL_GREED_TREASURE,
  },
})

end

If you have a big mod.

local MyMod = RegisterMod("Super Mod", 1)
local FunkyItem = Isaac.GetItemIdByName("Funky Item")

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

if Encyclopedia then

Encyclopedia.AddItem({
  Class = "Funky Kong Pack (25+ Items)",
  ID = FunkyItem,
  WikiDesc = Encyclopedia.EIDtoWiki(FunkyDescrption),
  Pools = {
    Encyclopedia.ItemPools.POOL_TREASURE,
    Encyclopedia.ItemPools.POOL_GREED_TREASURE,
  },
})

end

If you have custom display system.

local MyMod = RegisterMod("Super Mod", 1)
local FunkyItem = Isaac.GetItemIdByName("Funky Item")

if Encyclopedia then

Encyclopedia.AddItem({
  Class = "Funky Kong Pack (25+ Items)",
  ID = FunkyItem,
  StatusFunc = function(self)
    -- Displays a random itempool every time the menu is updated.
    self.Pools = {math.random(1, Encyclopedia.ItemPools.NUM_ITEM_POOLS}

    return self
  end,
})

end

Clone this wiki locally