The Binding of Isaac: Rebirth

The Binding of Isaac: Rebirth

79 ratings
!!~ Better CurseAPI
   
Award
Favorite
Favorited
Unfavorite
File Size
Posted
Updated
87.462 KB
13 Jan, 2024 @ 8:01pm
4 Mar @ 1:22pm
4 Change Notes ( view )
You need DLC to use this item.

Subscribe to download
!!~ Better CurseAPI

Description
Requires MiniMAPI

Found a bug? Want to contribute? Check out Better CurseAPI's GitHub repository![github.com]

I was unsatisfied with CurseAPI, so I made my own better version.

Here's a list of the improvements over CurseAPI
- Uses the stage seed instead of math.random
- Compatible with MiniMAPI
- Doesn't override the game's actual curse chance
- Allows custom functions to determine if a curse is allowed to spawn on a given floor
- Allows differently weighted curses
- Allows generating multiple curses on a floor (That's off by default, don't worry)
- Uses Game():GetLevel():CanStageHaveCurseOfLabyrinth() instead of trying to compute it manually
- Puts itself at the top of the mod list so you don't have to add ~ before your mod name to get the right load order

How to use Better CurseAPI
(If you need an example for any of these steps, download the Example Curse mod[github.com] from GitHub and look at the code)
1. Add your curse to content/curses.xml

2. Call BetterCurseAPI:registerCurse(curse_name, curse_weight, is_allowed_function, curse_icon) and store the return value in a local variable. That's your curse id. You'll need it later.
curse_name is the same name you used in curses.xml
curse_weight is the relative chance for a curse to appear, it is either a number or a function that returns a number. If unsure, make this value 1.0
is_allowed_function is either a boolean value, or a function that returns true if your curse is allowed on this floor and false if it isn't. If unsure, make it true.
curse_icon is either nil, or a table in the order of { sprite, animation name, animation frame }. If nil, your curse will not have an icon (This is not recommended).

3. Your curse is now registered. Use BetterCurseAPI:isCurseActive(curse_id) with the curse id from step 2 to check if your curse is currently active.

4. (Technically optional, but recommended) Add your curse to the Better CurseAPI mod config menu page. Be sure to check if mod config menu is installed first. You are responsible for saving and loading the user configuration for any custom curses you add. Better CurseAPI will not store it for you.

The easiest way is to use BetterCurseAPI:addCurseConfig(curse_id, paramsTable).
curse_id is the curse id from step 2.

paramsTable is a table with the following keys.
enabled_current_setting is a function that returns true if the curse is currently enabled, and false if it is disabled.
on_change_enabled is a function that takes 1 parameter, which is true if the curse is being enabled, and false if it is being disabled.
default_enabled is either true or false, indicating whether the curse is enabled by default.
on_weight_change is a function that takes 1 parameter, which is a number equal to the new weight value being set.
default_weight is a number equal to the default weight value.
text is an optional parameter to display text below a curse's name. I recommend something like "Added by 'MOD_NAME' (Version 1.0)".
23 Comments
Kattack 4 Mar @ 3:56pm 
That would be hype, even if rgon doesn't implement such a thing it would still be very helpful if you could find some other way to have it work without minimapi (perhaps optionally)
Kitty McTophat  [author] 4 Mar @ 12:58pm 
Ah, I wasn't aware of Repentogon having its own minimap system. I'll look into that and try to make an update
fraZ0R 2 Mar @ 2:13pm 
MiniMapAPI is extremely laggy due to completely reimplementing the minimap system and redrawing it every tick, doesn't Repentogon offer its own way of doing minimap stuff without it? Would there be a way to make this API not depend on mmapi?
Kattack 11 Dec, 2024 @ 8:21am 
Yo you got the debug text enabled on the release version !!! can you turn it off it is spammy pls thx
lil gaggle 17 Nov, 2024 @ 3:55pm 
im I reading enchantment table what does this mean
PhotoFinn 30 Jul, 2024 @ 2:47pm 
Hello there! Me again, I don't know if you guys are still working on this mod, but if you are, I've just released an update to Accursed that includes several new callbacks that you guys can use to make your mod compatible with ours
Busybody64 4 May, 2024 @ 11:01am 
Repentogon?
PhotoFinn 22 Apr, 2024 @ 5:15pm 
Hey there! I'm the commissioner of the Accursed mod, just thought I'd relay some information the coder (Catto) gave to me regarding compatibility with this, as someone mentioned it in the comments, and it was something I was interested in as well.

Unfortunately, Catto says that you guys will need to implement compatibility on your end instead of the other way around, due to the ways you guys implemented your mod's new features. Don't take this as pressure from us though!

We're planning to push an update for accursed soon-ish that includes helper functions to help with the porting process if you guys happen to be interested :)
Guineatown20806 25 Mar, 2024 @ 10:27am 
How can I add curses of mods? Like the ones from the eclipsed mod
Kitty McTophat  [author] 19 Feb, 2024 @ 9:07am 
Yes, the custom curses will be prevented by black candle and removed by dagaz