Skip to content

API functions and enums

Valentin Lamprière edited this page Aug 13, 2022 · 5 revisions

Enums

ModCallbacks

  • POST_MACHINE_UPDATE
  • POST_PLAYER_TOUCH_MACHINE
  • POST_MACHINE_DESTROY
  • POST_FAMILIAR_FIRE_TEAR
  • POST_TEAR_INIT
  • POST_LASER_INIT
  • POST_FAMILIAR_FIRE_LASER
  • POST_FAMILIAR_TEAR_UPDATE
  • GET_LOSE_COLLECTIBLE
  • GET_LOSE_TRINKET
  • PRE_GET_FAMILIAR_FROM_SEWING_MACHINE
  • POST_GET_FAMILIAR_FROM_SEWING_MACHINE
  • FAMILIAR_UPDATE,
  • FAMILIAR_HIT_NPC
  • FAMILIAR_KILL_NPC
  • POST_FAMILIAR_PLAY_ANIM
  • POST_FAMILIAR_NEW_ROOM
  • ON_FAMILIAR_UPGRADED
  • POST_FAMILIAR_NEW_LEVEL
  • PRE_FAMILIAR_TEAR_COLLISION
  • FAMILIAR_CLEAN_ROOM
  • PRE_ADD_FAMILIAR_IN_SEWING_MACHINE
  • ON_FAMILIAR_LOSE_UPGRADE
  • FAMILIAR_EVALUATE_CACHE
  • PRE_FAMILIAR_COLLISION
  • FAMILIAR_PLAYER_TAKE_DAMAGE
  • POST_FAMILIAR_INIT

FamiliarLevel

  • NORMAL
  • SUPER
  • ULTRA

FamiliarLevelFlag

  • FLAG_NORMAL
  • FLAG_SUPER
  • FLAG_ULTRA
  • FLAG_ANY

NoUpgrade

  • NONE
  • MACHINE
  • TEMPORARY
  • ANY

Functions

Is Super

Check if a familiar is upgraded as SUPER (gold crown)

Sewn_API:IsSuper(fData, includeUltra)
  • [table] fData : The data attribute of the familiar, accessible with familiar:GetData()
  • [boolean] (optional) includeUltra : When true, return true if the familiar is SUPER or ULTRA, when false return true only when the familiar is SUPER. Default : true

Is Ultra

Check if a familiar is upgraded as ULTRA (diamond crown)

Sewn_API:IsUltra(fData)
  • [table] fData : The data attribute of the familiar, accessible with familiar:GetData()

Get Level

Get the level of the familiar

Sewn_API:GetLevel(fData)
  • [table] fData : The data attribute of the familiar, accessible with familiar:GetData()

Return : The FamiliarLevel of the familiar


Make Familiar Available

Make the given faliliar available for Sewing Machine.

Sewn_API:MakeFamiliarAvailable(familiarVariant, collectibleID)
  • [FamiliarVariant] familiarVariant
  • [CollectibleType] (optional) collectibleID : The collectible associated to the familiar. The sprite for this collectible will be seen in the Sewing Machine.
  • [Sprite] (optional) : The sprite to display in the machine. If not set, take the sprite from the collectible. If both aren't set, a question mark will be displayed.

Add Familiar Description

Add an EID description for familiar upgrades

Sewn_API:AddFamiliarDescription(familiarVariant, upgradeSuper, upgradeUltra, color, optionalName)
  • [FamiliarVariant] familiarVariant
  • [string] upgradeSuper : The text which will be seen for the SUPER upgrade
  • [string] upgradeUltra : The text which will be seen for the ULTRA upgrade
  • [table] color (optional) : The color of the familiar name text. It is a table with 3 numbers [0, 1]. Ex : {1, 0.8, 0.4}
  • [string] optionalName (optional) : The name of the familiar, will be displayed as the title. If not set the name of the associated collectible is taken. Note : it is marked optional but due to the last repentance patch it is impossible to get the name of collectibles, so it is recommended to enter the name of the familiar

Add Encyclopedia Upgrade

Add a wiki for familiar upgrades in the Encyclopedia. This will be added in the familiar item wiki.

It is possible to add 3 sections : Super upgrade, Ultra upgrade, Notes for additional informations.

By default the EID description is used in the Encyclopedia.

Sewn_API:AddEncyclopediaUpgrade(familiarVariant, wikiUpgradeSuper, wikiUpgradeUltra, wikiNotes)
  • [FamiliarVariant] familiarVariant
  • [string] wikiUpgradeSuper (optional) : The wiki of the super upgrade. If not set, it will choose the EID description
  • [string] wikiUpgradeUltra (optional) : The wiki of the ultra upgrade. If not set, it will choose the EID description
  • [string] wikiNotes (optional) : Additional notes for the upgrade.

Add Callback

Add a callback related to Sewing Machines and upgrades

Sewn_API:AddCallback(callbackID, func, ...)
  • [Sewn_API.Enums.ModCallbacks] callbackID : The callback ID
  • [function] func : The function which will be called
  • [...] (optional) ... : Additional arguments, depending on the called callback (see Sewing Machine Mod Callbacks)

Hide Crown

Hide or show the crown for a familiar. Useful if the familiar is dead, hidden etc.

Sewn_API:HideCrown(familiar, hideCrown)
  • [EntityFamiliar] familiar : The familiar you want to hide/unhide the crown to
  • [boolean] (optional) hideCrown : True to hide the crown, false to unhide it. Default is true

Up Familiar

Upgrade the given familiar and call the ON_FAMILIAR_UPGRADED callbacks. Useful for Peeper Eye which upgrade it copy.

Sewn_API:UpFamiliar(familiar, newLevel)
  • [EntityFamiliar] familiar : The familiar you want to upgrade
  • [Sewn_API.Enums.FamiliarLevel] newLevel: The level to set

Add Crown Offset

Add an offset to the familiar's crown.

Sewn_API:AddCrownOffset(familiar, offset)
  • [EntityFamiliar] familiar
  • [Vector] offset : The offset