Better CurseAPI

If you liked this item, please rate it up on Steam Workshop page.

Author: Kitty McTophat

Last revision: 2 Feb at 02:50 UTC (1)

File size: 73.33 KB

On Steam Workshop

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)".

Download
Required DLC:

These DLC should be installed in order to use this item.


The Binding of Isaac: Repentance
Required items:

Click the title to search on this site.


[AB+|Rep] MiniMAPI: A Minimap APISteam Workshop
Revisions:

Old revisions of this mod are available below. Click the link to download.