Items - Active
Author(s): benevolusgoatTags:
Crash course table of contents
The crash course is still a work in progress!
- Creating a mod.
- Creating a passive item.
- Creating an active item.
- Adding to item pools.
- Making costumes.
- Making a new character.
- Creating entities.
- Creating effects.
- Creating enemies.
- Creating a familiar.
- Creating a projectile variant.
- Creating a tear variant.
- Adding sounds.
- Adding music.
- Making pocket items.
- Creating custom pills.
- Creating custom cards.
- Creating custom runes.
- Creating custom objects.
- Creating challenges.
- Creating new curses.
- Structuring your mod.
- Conclusion.
Active items are items held in the active slot and usually require charge to be used. This tutorial will branch off of the passive items page, so be sure to read that first.
Video tutorial⚓︎
(This tutorial covers both Item Pools and Active Items)
Creating your active item⚓︎
The process of creating an active item is identical to that of a passive item, replacing the passive
tag with active
. However, there are a few unique attributes exclusive to active items.
1 2 3 |
|
active
-exclusive tag variables
Note
All tags are optional.
Variable Name | Possible Values | Description |
---|---|---|
maxcharges | int | 0 by default. When chargetype is set to timed , this attribute is used to define the cooldown of the item in game ticks. 30 = 1 second. |
chargetype | string | normal by default. Possible values: [normal , timed , special ]. |
passivecache | bool | false by default. Calls a cache evaluation when picked up similar to passive items, as typically the cache flag for active items will only trigger upon item activation. |
Explaining charge types⚓︎
There are three charge types an active item can have that affect its charging behavior.
normal
: The standard, default method of charging. Charges through room clears, battery pickups, and other conventional methods. Vanilla only uses max charges of [0
,1
,2
,3
,4
,6
,8
,12
], but there is support for any number from 0 to 12.timed
: Can charge all the same waysnormal
charge type items do. Will automatically fill its chargebar over time.special
: Cannot be charged through any conventional means, and must be charged manually with Lua code.
Coding the active item⚓︎
The active item now exists, but does not do anything on its own upon activation. This will require Lua code in order to give it an effect when used. The crucial callback for active items is ModCallbacks.MC_USE_ITEM.
Inside your main.lua
, get your active item's ID and create a function attached to the MC_USE_ITEM
callback.
1 2 3 4 5 6 7 8 9 10 11 12 |
|
For this example, this item will kill every enemy in the room upon use.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
|
Adding charges manually⚓︎
If you have a chargetype
of special
, you will require the use of EntityPlayer:SetActiveCharge. If you have
REPENTOGON, you can also use EntityPlayer:AddActiveCharge and set the Force
argument to true
.
This snippet of code will loop through the player's inventory of active items (active items can appear in multiple different slots) and increase each item's charge by 1 every 10 seconds.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
|