The Binding of Isaac: Rebirth

The Binding of Isaac: Rebirth

Stackable Damocles | +Easy to use API
 This topic has been pinned, so it's probably important
AgentCucco  [developer] 18 Jun, 2021 @ 9:36pm
API Documentation
Using the API is really easy to do, if you wanna add your own item duplication stuff.

How to load the mod:
To load the mod, all you have to do is bundle this mod's 'damocles_api.lua' file with your mod, and do this after registering your mod:
-- RegisterMod and variables require("damocles_api")

Note that you HAVE TO use require(), using include() will load multiple copies of DamoclesAPI if multiple mods use the library, and completely break. Likewise, since this library needs require(), you will not be able to use the luamod debug command to reload any mod that uses it, you will need to menuload (double tab the mods menu) instead.

How to add my own duplication setup:
To add your own duplication setups, all you have to do is use the following function:
CCO.DamoclesAPI.AddDamoclesCallback(myfunction)

Here's an example of a function you can add:
local function DeathCounter() local DamoclesCount = 0 for p = 0, game:GetNumPlayers() - 1 do local player = Isaac.GetPlayer(p) local data = player:GetData() if data.DeathCounter then DamoclesCount = DamoclesCount + data.DeathCounter end end return DamoclesCount end CCO.DamoclesAPI.AddDamoclesCallback(DeathCounter)

Note that you ALWAYS have to 'return' a numeric value, otherwise the mod's gonna error.

How to prevent custom spawned items from getting duplicated:
Maybe you made a custom duplication setup for a specific circumstance in your project, and you don't Damocles or supported mods to duplicate your item. All you really need to do to prevent this is simple, when you spawn the item, just assign it the following GetData() tag:
local NewItem = Isaac.Spawn(...) -- spawn the item as you would normally. NewItem:GetData().DamoclesDuplicate = true

This is everything you need to know to use this mod's API.
Last edited by AgentCucco; 20 Oct, 2023 @ 2:07pm