Item
┗> Class
The Item class represents all types of item in Kristal.
Items are data files contained in scripts/data/items that should extend this class or one of its extensions (see below), and their filepath starting at this location becomes their id, unless an id for them is specified as the second argument to Class().
There are extensions of item that provide additional functionality when extended from: HealItem and TensionItem
Items that are Light World equipment should extend LightEquipItem instead of this class (it provides all of the same fields and functions as Item).
Items can be given to the player directly in the code through Inventory:addItem().
Methods
Item:addFlag(name: string, amount: number?)
Adds to the value of a numerical item-specific flag
Arguments:
| name: string | The name of the flag to change |
| amount: number? | The value to increment the flag by (defaults to |
Returns:
| new_value: number |
Item:applyHealBonus(current_heal: number, base_heal: number, healer: PartyMember)
(Override) Applies bonus healing to healing actions performed by a party member in battle
Arguments:
| current_heal: number | The current heal amount with other bonuses applied |
| base_heal: number | The original heal amount |
| healer: PartyMember | The character performing the heal |
Returns:
| new_heal: number | The new heal amount affected by this item |
Item:applyMoneyBonus(gold: number)
(Override) If the item grants bonus gold, it applies its bonus here
Arguments:
| gold: number | The current amount of victory gold |
Returns:
| new_gold: number | The amount of gold with the bonus applied |
Item:canEquip(character: PartyMember, slot_type: string, slot_index: number)
Gets whether a particular character can equip an item
Arguments:
| character: PartyMember | The character to check equippability for |
| slot_type: string | The type of equipment slot, either |
| slot_index: number | The index of the slot the item is being equipped to |
Returns:
| can_equip: boolean |
Item:convertToDark(inventory: DarkInventory?)
(Override) Converts this item into its dark counterpart, if it has one
Arguments:
| inventory: DarkInventory? | A type of inventory used to store items in the Dark World. |
Returns:
| result: boolean|Item |
|
Item:convertToDarkEquip(chara: PartyMember)
(Override) Converts an equipped item to its dark counterpart
Arguments:
| chara: PartyMember | The PartyMember class is a type of data class that stores information about a member of the party. |
Returns:
| 1: boolean|Item |
Item:convertToLight(inventory: LightInventory?)
(Override) Converts this item into its light counterpart, if it has one
Arguments:
| inventory: LightInventory? | A type of inventory used to store items in the Light World. |
Returns:
| result: boolean|Item |
|
Item:convertToLightEquip(chara: PartyMember)
(Override) Converts an equipped item to its light counterpart
Arguments:
| chara: PartyMember | The PartyMember class is a type of data class that stores information about a member of the party. |
Returns:
| 1: boolean|Item |
Item:createResultItem()
(Override) Creates an instance of this Item's specified result_item
Returns:
| result_item: Item |
Item:getAttackPitch(battler: any, enemy: any, points: any)
Arguments:
| battler: any | |
| enemy: any | |
| points: any |
Item:getAttackSound(battler: any, enemy: any, points: any)
Arguments:
| battler: any | |
| enemy: any | |
| points: any |
Item:getAttackSprite(battler: any, enemy: any, points: any)
Arguments:
| battler: any | |
| enemy: any | |
| points: any |
Item:getBattleText(user: PartyBattler, target: Battler[]|EnemyBattler|EnemyBattler[]|PartyBattler|PartyBattler[])
(Override) Gets the text displayed when the item is used in battle
Arguments:
| user: PartyBattler |
|
| target: Battler[]|EnemyBattler|EnemyBattler[]|PartyBattler|PartyBattler[] |
|
Returns:
| 1: string |
Item:getFlag(name: string, default: integer?)
Gets the value of an item-specific flag
Arguments:
| name: string | The name of the flag to get the value from |
| default: integer? | An optional default value to return if the flag is |
Returns:
| 1: integer |
Item:getReaction(user_id: string, reactor_id: string)
Gets the reaction for using or equipping an item for a specific user and reactor
Arguments:
| user_id: string | The id of the character using/equipping the item |
| reactor_id: string | The id of the character to get a reaction for |
Returns:
| reaction: string? |
Item:getStatBonus(stat: string)
Gets the stat bonus an item has for a specific stat
Arguments:
| stat: string |
Returns:
| bonus: number |
Item:isEquippedBy(character: PartyMember)
Gets whether this item instance is equipped by the specified party member
Arguments:
| character: PartyMember | The character to check the equipment of |
Returns:
| equipped: boolean |
Item:load(data: table)
Unpacks a table of Item save data into fields on the class
Arguments:
| data: table |
Item:onAttackHit(battler: PartyBattler, enemy: EnemyBattler, damage: number)
(Override) Called after an attack from a party member with this item equipped hits an enemy
Arguments:
| battler: PartyBattler | The attacking character |
| enemy: EnemyBattler | The enemy hit by the attack |
| damage: number | The attack's final damage (can be 0) |
Item:onBattleDamage(amount: The, swoon: Whether, all: Whether)
(Override) Called before a PartyBattler takes damage
Arguments:
| amount: The | damage of the incoming hit |
| swoon: Whether | the damage will swoon the battler instead of downing them |
| all: Whether | the damage being taken comes from a strike targeting the whole party |
Returns:
| New: number? | damage amount |
Item:onBattleDeselect(user: PartyBattler, target: Battler[]|EnemyBattler|EnemyBattler[]|PartyBattler|PartyBattler[])
(Override) Called when the item use is undone in the menu
Arguments:
| user: PartyBattler |
|
| target: Battler[]|EnemyBattler|EnemyBattler[]|PartyBattler|PartyBattler[] |
|
Item:onBattleSelect(user: PartyBattler, target: Battler[]|EnemyBattler|EnemyBattler[]|PartyBattler|PartyBattler[])
(Override) Called when the item is selected for use in battle
Arguments:
| user: PartyBattler |
|
| target: Battler[]|EnemyBattler|EnemyBattler[]|PartyBattler|PartyBattler[] |
|
Item:onBattleUpdate(battler: PartyBattler)
(Override) Called every frame in batle when this item is equipped
Arguments:
| battler: PartyBattler | The equipping character |
Item:onBattleUse(user: PartyBattler, target: Battler[]|EnemyBattler|EnemyBattler[]|PartyBattler|PartyBattler[])
(Override) Called when the item is used in battle
Arguments:
| user: PartyBattler |
|
| target: Battler[]|EnemyBattler|EnemyBattler[]|PartyBattler|PartyBattler[] |
|
Item:onCheck()
(Override) Called when the item is checked
*By default, responisble for displaying the check message
Item:onEquip(character: PartyMember, replacement: Item?)
(Override) Called when the player tries to equip this item on a character
If the function returns false, the item will not be equipped
Arguments:
| character: PartyMember | The party member equipping the item |
| replacement: Item? | The item currently in the slot, if one is present |
Returns:
| equipped: boolean |
Item:onMenuClose(menu: DarkMenu)
(Override) Called when the menu containing this item is closed (only in Dark World)
Arguments:
| menu: DarkMenu |
Item:onMenuDraw(menu: DarkMenu)
(Override) Called whenever the menu draws when it is open to the storage containing this item (only in Dark World)
Arguments:
| menu: DarkMenu |
Item:onMenuOpen(menu: DarkMenu)
(Override) Called when the menu containing this item is opened (only in Dark World)
Arguments:
| menu: DarkMenu |
Item:onMenuUpdate(menu: DarkMenu)
(Override) Called whenever the menu updates when it is open to the storage containing this item (only in Dark World)
Arguments:
| menu: DarkMenu |
Item:onToss()
(Override) Called when the item is tossed
By default, responsible for displaying a random toss message when in the Light World
Returns:
| success: boolean | Whether the item was successfully tossed - return |
Item:onUnequip(character: any, replacement: any)
Arguments:
| character: any | |
| replacement: any |
Returns:
| 1: boolean |
Item:onWorldDamage(amount: The)
(Override) Called before a Character takes damage from a world bullet
Arguments:
| amount: The | damage of the incoming hit |
Returns:
| New: number? | damage amount |
Item:onWorldUpdate(chara: Character)
(Override) Called every frame in the overworld when this item is equipped
Arguments:
| chara: Character | The equipping character |
Item:onWorldUse(target: PartyMember|PartyMember[])
(Override) Called when the item is used in the overworld
Arguments:
| target: PartyMember|PartyMember[] | The PartyMember class is a type of data class that stores information about a member of the party. |
Item:setFlag(name: string, value: any)
Sets the value of an item-specific flag
Arguments:
| name: string | The name of the flag to set |
| value: any | The value to set the flag to |
Fields
Item.light_item: Item
The Item class represents all types of item in Kristal.
Items are data files contained in scripts/data/items that should extend this class or one of its extensions (see below), and their filepath starting at this location becomes their id, unless an id for them is specified as the second argument to Class().
There are extensions of item that provide additional functionality when extended from: HealItem and TensionItem
Items that are Light World equipment should extend LightEquipItem instead of this class (it provides all of the same fields and functions as Item).
Items can be given to the player directly in the code through Inventory:addItem().