Constructor






Methods


Item:addFlag(name: string, amount: number?)

Adds to the value of a numerical item-specific flag

@param name — The name of the flag to change

@param amount — The value to increment the flag by (defaults to 1)

Arguments:

name: string

The name of the flag to change

amount: number?

The value to increment the flag by (defaults to 1)

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

@param current_heal — The current heal amount with other bonuses applied

@param base_heal — The original heal amount

@param healer — The character performing the heal

@return new_heal — The new heal amount affected by this item

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

@param gold — The current amount of victory gold

@return new_gold — The amount of gold with the bonus applied

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

@param character — The character to check equippability for

@param slot_type — The type of equipment slot, either "weapon" or "armor"

@param slot_index — The index of the slot the item is being equipped to

Arguments:

character: PartyMember

The character to check equippability for

slot_type: string

The type of equipment slot, either "weapon" or "armor"

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

@return resulttrue if the item sucessfully converts and stores, and false if there is no item to convert. If the dark_location is unset, returns the converted item

Arguments:

inventory: DarkInventory?

A type of inventory used to store items in the Dark World.

Returns:

result: boolean|Item

true if the item sucessfully converts and stores, and false if there is no item to convert. If the dark_location is unset, returns the converted 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.
PartyMembers are stored in scripts/data/party, and extend this class. Their filepath starting from here becomes their id, unless an id is specified as an argument to Class().

Returns:

1: boolean|Item


Item:convertToLight(inventory: LightInventory?)

(Override) Converts this item into its light counterpart, if it has one

@return resulttrue if the item sucessfully converts and stores, and false if there is no item to convert. If the light_location is unset, returns the converted item

Arguments:

inventory: LightInventory?

A type of inventory used to store items in the Light World.

Returns:

result: boolean|Item

true if the item sucessfully converts and stores, and false if there is no item to convert. If the light_location is unset, returns the converted 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.
PartyMembers are stored in scripts/data/party, and extend this class. Their filepath starting from here becomes their id, unless an id is specified as an argument to Class().

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

PartyBattlers are a type of Battler that represent PartyMembers when they are in battle.
The set of PartyBattlers in the current battle are stored in Game.battle.party.
Unlike EnemyBattler, party members do not need to define a PartyBattler in a file as their PartyMember file defines everything necessary and is utilised by PartyBattler.

target: Battler[]|EnemyBattler|EnemyBattler[]|PartyBattler|PartyBattler[]

PartyBattlers are a type of Battler that represent PartyMembers when they are in battle.
The set of PartyBattlers in the current battle are stored in Game.battle.party.
Unlike EnemyBattler, party members do not need to define a PartyBattler in a file as their PartyMember file defines everything necessary and is utilised by PartyBattler.

Returns:

1: string








Item:getCheck()

Returns:

1: string




Item:getFlag(name: string, default: integer?)

Gets the value of an item-specific flag

@param name — The name of the flag to get the value from

@param default — An optional default value to return if the flag is nil

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 nil

Returns:

1: integer


Item:getName()

Returns:

1: string


Item:getPrice()

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

@param user_id — The id of the character using/equipping the item

@param reactor_id — The id of the character to get a reaction for

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:getUseName()

Returns:

1: string






Item:isEquippedBy(character: PartyMember)

Gets whether this item instance is equipped by the specified party member

@param character — The character to check the equipment of

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

@param battler — The attacking character

@param enemy — The enemy hit by the attack

@param damage — The attack's final damage (can be 0)

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:onBattleDeselect(user: PartyBattler, target: Battler[]|EnemyBattler|EnemyBattler[]|PartyBattler|PartyBattler[])

(Override) Called when the item use is undone in the menu

Arguments:

user: PartyBattler

PartyBattlers are a type of Battler that represent PartyMembers when they are in battle.
The set of PartyBattlers in the current battle are stored in Game.battle.party.
Unlike EnemyBattler, party members do not need to define a PartyBattler in a file as their PartyMember file defines everything necessary and is utilised by PartyBattler.

target: Battler[]|EnemyBattler|EnemyBattler[]|PartyBattler|PartyBattler[]

PartyBattlers are a type of Battler that represent PartyMembers when they are in battle.
The set of PartyBattlers in the current battle are stored in Game.battle.party.
Unlike EnemyBattler, party members do not need to define a PartyBattler in a file as their PartyMember file defines everything necessary and is utilised by 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

PartyBattlers are a type of Battler that represent PartyMembers when they are in battle.
The set of PartyBattlers in the current battle are stored in Game.battle.party.
Unlike EnemyBattler, party members do not need to define a PartyBattler in a file as their PartyMember file defines everything necessary and is utilised by PartyBattler.

target: Battler[]|EnemyBattler|EnemyBattler[]|PartyBattler|PartyBattler[]

PartyBattlers are a type of Battler that represent PartyMembers when they are in battle.
The set of PartyBattlers in the current battle are stored in Game.battle.party.
Unlike EnemyBattler, party members do not need to define a PartyBattler in a file as their PartyMember file defines everything necessary and is utilised by PartyBattler.



Item:onBattleUpdate(battler: PartyBattler)

(Override) Called every frame in batle when this item is equipped

@param battler — The equipping character

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

PartyBattlers are a type of Battler that represent PartyMembers when they are in battle.
The set of PartyBattlers in the current battle are stored in Game.battle.party.
Unlike EnemyBattler, party members do not need to define a PartyBattler in a file as their PartyMember file defines everything necessary and is utilised by PartyBattler.

target: Battler[]|EnemyBattler|EnemyBattler[]|PartyBattler|PartyBattler[]

PartyBattlers are a type of Battler that represent PartyMembers when they are in battle.
The set of PartyBattlers in the current battle are stored in Game.battle.party.
Unlike EnemyBattler, party members do not need to define a PartyBattler in a file as their PartyMember file defines everything necessary and is utilised by 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

@param character — The party member equipping the item

@param replacement — The item currently in the slot, if one is present

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:onLoad(data: table)

(Override) Called when the item is loaded

Arguments:

data: table


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:onSave(data: table)

(Override) Called when the item is saved

Arguments:

data: table


Item:onToss()

(Override) Called when the item is tossed
By default, responsible for displaying a random toss message when in the Light World

@return success — Whether the item was successfully tossed - return false to cancel tossing

Returns:

success: boolean

Whether the item was successfully tossed - return false to cancel tossing



Item:onUnequip(character: any, replacement: any)

Arguments:

character: any
replacement: any

Returns:

1: boolean


Item:onWorldUpdate(chara: Character)

(Override) Called every frame in the overworld when this item is equipped

@param chara — The equipping character

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.
PartyMembers are stored in scripts/data/party, and extend this class. Their filepath starting from here becomes their id, unless an id is specified as an argument to Class().



Item:save()

Compacts the item's data into a table for saving

Returns:

1: table


Item:setFlag(name: string, value: integer)

Sets the value of an item-specific flag

@param name — The name of the flag to set

@param value — The value to set the flag to

Arguments:

name: string

The name of the flag to set

value: integer

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().














Undocumented