Skip to main content

Custom Pickups

Hierarchy

  • Feature

    CustomPickups

Methods

registerCustomPickup

registerCustomPickup(pickupVariantCustom, subType, collectFunc, collisionFunc?): void

Helper function to register a custom pickup with the IsaacScript standard library. Use this feature for custom pickups that are intended to be picked up by the player, like bombs and keys.

When IsaacScript detects that a player should be collecting the custom pickup, then the pickup will be immediately removed, and an effect showing the pickup's respective Collect animation will be spawned. (This emulates how a normal vanilla pickup would work.) After that, the provided collectFunc will be fired. In this function, you will probably want to play a sound corresponding to what kind of pickup it is (e.g. SoundEffect.KEY_PICKUP_GAUNTLET), as well as do things like adding something to the player's inventory.

Note that when you specify your custom pickup in the "entities2.xml" file, it should have a type of "5" and be associated with an anm2 file that has a "Collect" animation.

In order to use this function, you must upgrade your mod with ISCFeature.CUSTOM_PICKUPS.

Parameters

NameTypeDescription
pickupVariantCustomPickupVariantThe variant for the corresponding custom pickup.
subTypeintThe sub-type for the corresponding custom pickup.
collectFunc(this: void, player: EntityPlayer) => voidThe function to run when the player collects this pickup.
collisionFunc(this: void, player: EntityPlayer) => booleanOptional. The function to run when a player collides with the pickup. Default is a function that always returns true, meaning that the player will always immediately collect the pickup when they collide with it. Specify this function if your pickup should only be able to be collected under certain conditions.

Returns

void

Defined in

packages/isaacscript-common/src/classes/features/other/CustomPickups.ts:137