-
Notifications
You must be signed in to change notification settings - Fork 0
Using Modifiers
Sanio edited this page Oct 5, 2024
·
10 revisions
With modifiers, you can further adjust sprites based on any conditions of your choosing.
Modifiers are great ways to update a Unique Object for any reason you may have, notably if you plan on making multiple different sprites for the same character. The structure for modifiers here is built very similarly to how External Item Descriptions (EID) handles modifiers.
UniqueItemsAPI.AssignObjectModifier(string modifierName, function condition, function callback, UniqueObjectType objectType)
Assigns a modifier to the specified object group. For both functions, they have a single argument params that contain all the same params you may have assigned in AssignUniqueObject in addition to three more:
- Player
EntityPlayer: The player that is being used for the current Unique Object. - ModName
string: Name of the mod/pack that is being used for the current Unique Object. - ObjectEntity
EntityThe entity being used for the unique sprite. This can be a collectible, knife, familiar, player, or tear (for Spirit Sword)
-
modifierName: Name of your modifier, used as an identifier. -
condition: Function for containing whatever conditions you wish. Return true in order to activate yourcallbackfunction. -
callback: Is called wheneverconditionreturns true. Return theparamstable when you're finished modifying it. -
objectType: Follows theUniqueItemsAPI.ObjectTypeenum.
For removing modifiers by name.
-
modifierName: Name of the modifier to remove. -
objectType: Follows theUniqueItemsAPI.ObjectTypeenum.
-- The only thing the code checks for is if "true" is returned. Anything else returned will result in the condition failing.
local function IsMyDeleted(itemParams)
return theDeletedMode ~= nil
and itemParams.PlayerType == Isaac.GetPlayerTypeByName("Deleted", false)
and itemParams.ObjectID == CollectibleType.COLLECTIBLE_BIRTHRIGHT
end
local function DeletedBirthrightForms(params)
params.SpritePath = {string.gsub(params.SpritePath[1], "birthright.png", "birthright_" .. theDeletedMode .. ".png")}
return itemParams
end
UniqueItemsAPI.AddObjectModifier("THE DELETED Birthright Forms", IsMyDeleted, DeletedBirthrightForms, UniqueItemsAPI.ObjectType.COLLECTIBLE)