Class Spell

Methods

spell:init (data) Initiate a spell from its definition.
spell:get_description (no_reqtext) Get the description of the spell, its cost, and potentially a description of why you can't use it.
spell:get_info () Returns all the stats of the spell
spell:target (target, caster, ignoreCooldowns) Start targeting a spell (unless it's a self-only spell, in which case it just goes ahead and casts it).
spell:use (target, caster, ignoreCooldowns, ignoreCost) Cast a spell.
spell:can_use (target, caster, ignoreCooldowns, ignoreCost) Checks to see if the spell can be used right now
spell:advance_active (target, caster, ignoreCooldowns, ignoreCost) Placeholder for the advance_active() callback, which is called every turn a spell is active
spell:finish (target, caster, ignoreCooldowns, ignoreCost) Placeholder for the finish() callback, which is called when a spell is toggled off or stops being channeled.
spell:decide (target, caster, use_type) Placeholder for the decide() callback, which is used by the AI to decide where to target a spell.
spell:requires (possessor) Placeholder for the requires() callback, used to determine if the creature meets the requirements for using the spell
spell:target_requires (target, caster, previous_targets) Placeholder for the target_requires() callback, used to determine if the attempted target of the spell is acceptable
spell:learn_requires (possessor) Placeholder for the learn_requires() callback, used to determine if the creature meets the requirements for using the spell
spell:get_target_tiles (target, possessor, previous_targets) Placeholder for the get_target_tiles() function
spell:has_tag (tag) Checks if a spell has a descriptive tag.
spell:is_type (tag) Checks if a spell is of a specific type
spell:get_stat (stat, possessor, noBonus) Get the stat for a spell
spell:get_possible_upgrades (use_requirements.) Gets the possible upgrades for a spell
spell:can_upgrade (upgrade) Determines whether you're able to perform an upgrade
spell:get_upgrade_cost (upgradeID) Gets the costs associated with a spell upgrade
spell:apply_upgrade (upgradeID, force) Applies an upgrade to a spell
spell:get_appliable_items (possessor) Get upgrade items that can be applied to a spell
spell:apply_item (item) Apply an item to a spell, gaining its bonuses
spell:upgrade_requires (possessor, upgradeID) Placeholder for the upgrade_requires() callback, used to determine if the creature meets the requirements for upgrading the spell
spell:get_potential_targets (caster, previous_targets) Gets potential targets of a spell.
spell:get_setting (settingID) Get the value of a spell setting
spell:setting_available (settingID) Checks whether a spell setting is available
spell:toggle_setting (settingID) Toggle a setting on or off
spell:update_charges (amount, silent) Update the charges for a spell


Methods

spell:init (data)
Initiate a spell from its definition. You shouldn't use this function, the game uses it at loadtime to instantiate the spells.

Parameters:

  • data Table. The table of spell information.

Returns:

    Spell. The spell itself.
spell:get_description (no_reqtext)
Get the description of the spell, its cost, and potentially a description of why you can't use it.

Parameters:

  • no_reqtext Boolean. If true, don't show the text that explains why you can't use the ability.

Returns:

    String. The description of the spell.
spell:get_info ()
Returns all the stats of the spell

Returns:

    String. The stats of the spell
spell:target (target, caster, ignoreCooldowns)
Start targeting a spell (unless it's a self-only spell, in which case it just goes ahead and casts it).

Parameters:

  • target Entity. The target of the spell.
  • caster Creature. The caster of the spell.
  • ignoreCooldowns Boolean. If set to true, this will ignore whether or not the spell is on a cooldown.

Returns:

    Boolean. Whether the spell was successfully able to be cast/targeted or not.
spell:use (target, caster, ignoreCooldowns, ignoreCost)
Cast a spell.

Parameters:

  • target Entity. The target of the spell.
  • caster Creature. The caster of the spell.
  • ignoreCooldowns Boolean. If set to true, this will ignore whether or not the spell is on a cooldown.
  • ignoreCost Boolean. If set to true, this will make the spell not use MP when cast

Returns:

    Boolean. Whether the spell was successfully able to be cast or not.
spell:can_use (target, caster, ignoreCooldowns, ignoreCost)
Checks to see if the spell can be used right now

Parameters:

  • target Entity. The target of the spell.
  • caster Creature. The caster of the spell.
  • ignoreCooldowns Boolean. If set to true, this will ignore whether or not the spell is on a cooldown.
  • ignoreCost Boolean. If set to true, this will make the spell not use MP when cast

Returns:

    Boolean. Whether the spell can be used right now
spell:advance_active (target, caster, ignoreCooldowns, ignoreCost)
Placeholder for the advance_active() callback, which is called every turn a spell is active

Parameters:

  • target Entity. The target of the spell.
  • caster Creature. The caster of the spell.
  • ignoreCooldowns Boolean. If set to true, this will ignore whether or not the spell is on a cooldown.
  • ignoreCost Boolean. If set to true, this will make the spell not use MP when cast

Returns:

    Boolean. False if the spell ends, true otherwise
spell:finish (target, caster, ignoreCooldowns, ignoreCost)
Placeholder for the finish() callback, which is called when a spell is toggled off or stops being channeled.

Parameters:

  • target Entity. The target of the spell.
  • caster Creature. The caster of the spell.
  • ignoreCooldowns Boolean. If set to true, this will ignore whether or not the spell is on a cooldown.
  • ignoreCost Boolean. If set to true, this will make the spell not use MP when cast
spell:decide (target, caster, use_type)
Placeholder for the decide() callback, which is used by the AI to decide where to target a spell. Defaults to the already-selected target.

Parameters:

  • target Entity. The original target of the spell.
  • caster Creature. The creature casting the spell.
  • use_type String. The way in which this spell is being used. Either aggressive, defensive, fleeing or friendly.

Returns:

    Entity. The new target of the spell.
spell:requires (possessor)
Placeholder for the requires() callback, used to determine if the creature meets the requirements for using the spell

Parameters:

  • possessor Creature. The creature who's trying to use the spell.

Returns:

    true
spell:target_requires (target, caster, previous_targets)
Placeholder for the target_requires() callback, used to determine if the attempted target of the spell is acceptable

Parameters:

  • target Entity. The attempted target of the spell.
  • caster Creature. The creature who's trying to use the spell.
  • previous_targets Table. The already-targeted targets of the spell, if applicable

Returns:

    true
spell:learn_requires (possessor)
Placeholder for the learn_requires() callback, used to determine if the creature meets the requirements for using the spell

Parameters:

  • possessor Creature. The creature who's trying to use the spell.

Returns:

    true
spell:get_target_tiles (target, possessor, previous_targets)
Placeholder for the get_target_tiles() function

Parameters:

  • target Entity. The potential target of the spell
  • possessor Creature. The creature who's trying to use the spell.
  • previous_targets Table. The already-targeted targets of the spell, if applicable

Returns:

    true
spell:has_tag (tag)
Checks if a spell has a descriptive tag.

Parameters:

  • tag String. The tag to check for

Returns:

    Boolean. Whether or not it has the tag.
spell:is_type (tag)
Checks if a spell is of a specific type

Parameters:

  • tag String. The tag to check for

Returns:

    Boolean. Whether or not it has the tag.
spell:get_stat (stat, possessor, noBonus)
Get the stat for a spell

Parameters:

  • stat String. The stat to return
  • possessor Creature. The creature to look at when determine the spell's stats
  • noBonus Boolean. If true, don't apply any bonuses, just return the base stat

Returns:

    Anything. Whatever the stat's value is (or false if not set)
spell:get_possible_upgrades (use_requirements.)
Gets the possible upgrades for a spell

Parameters:

  • use_requirements. If true, only return upgrades that you meet the requirements for, otherwise return all upgrades that aren't maxed out

Returns:

    Table. A table of the possible upgrades, with the format {upgradeID=upgradeLevel}
spell:can_upgrade (upgrade)
Determines whether you're able to perform an upgrade

Parameters:

  • upgrade String. The ID of the upgrade
spell:get_upgrade_cost (upgradeID)
Gets the costs associated with a spell upgrade

Parameters:

  • upgradeID String. The ID of the upgrade
spell:apply_upgrade (upgradeID, force)
Applies an upgrade to a spell

Parameters:

  • upgradeID String. The ID of the upgrade to apply
  • force Boolean. If true, ignore upgrade requirements

Returns:

    Boolean. Whether the upgrade was applied
spell:get_appliable_items (possessor)
Get upgrade items that can be applied to a spell

Parameters:

  • possessor
spell:apply_item (item)
Apply an item to a spell, gaining its bonuses

Parameters:

  • item Item. The item to apply
spell:upgrade_requires (possessor, upgradeID)
Placeholder for the upgrade_requires() callback, used to determine if the creature meets the requirements for upgrading the spell

Parameters:

  • possessor Creature. The creature who's trying to upgrade the spell
  • upgradeID String. The ID of the upgrade

Returns:

    true
spell:get_potential_targets (caster, previous_targets)
Gets potential targets of a spell. Uses the spell's own get_potential_targets() function if it has one, or defaults to seen creatures if it doesn't and it's a creature-spell

Parameters:

  • caster Creature. The caster of the spell
  • previous_targets Table. The already-targeted targets of the spell, if applicable

Returns:

    Table. A list of potential targets
spell:get_setting (settingID)
Get the value of a spell setting

Parameters:

  • settingID

Returns:

    Boolean. Whether the setting is set or not
spell:setting_available (settingID)
Checks whether a spell setting is available

Parameters:

  • settingID

Returns:

    Boolean. Whether the setting is available or not
spell:toggle_setting (settingID)
Toggle a setting on or off

Parameters:

  • settingID String. The ID of the setting

Returns:

    Boolean. The setting's new value, false for off, true for on
spell:update_charges (amount, silent)
Update the charges for a spell

Parameters:

  • amount Number. The amount to change it by
  • silent Boolean. If true, don't show a popup
generated by LDoc 1.5.0 Last updated 2025-05-24 09:49:55