Class Feature
Methods
feature:init (feature_type, info, x, y) | Initiates a feature. |
feature:get_name (full) | Returns the name of the feature. |
feature:get_description () | Returns the description of the feature, and descriptive lines noting what you can do with it. |
feature:can_enter (enterer, fromX, fromY) | Calls the can_enter() function of a feature, if it has one. |
feature:enter (enterer, fromX, fromY) | Calls the enter() function of a feature, if it has one. |
feature:push (pusher) | Pushes a feature, if it's pushable. |
feature:moveTo (x, y, noTween) | Moves a feature to a new location. |
feature:damage (amt, source, damage_type, force, armor_piercing) | Damages a feature, destroying it if it has HP and the damage done was more than its HP. |
feature:calculate_damage_received (amt, damage_type, armor_piercing, ignoreWeakness) | Calculates the damage amount a feature would receive based on damage types, weaknesses, armor, etc |
feature:destroy (source, damage_type) | Destroy a feature. |
feature:delete (map) | Delete a feature from the map |
feature:refresh_image_name (map) | Refresh the image name of a feature. |
feature:is_hazardous_for (ctype) | Checks if a feature is hazardous for a certain creature type. |
feature:action (activator, actionID, args.) | Perform a feature's action() callback, if applicable. |
feature:action_requires (activator, actionID) | Check if a feature's action's requirements are met |
feature:take_item (taker, item) | Perform a feature's take_item() callback, if applicable. |
feature:cleanup (map) | Perform a feature's cleanup() callback, if applicable. |
feature:give_item (item) | Transfer an item to a feature's inventory |
feature:drop_item (item) | Have a feature "drop" an item it contains on to the tile it's on |
feature:drop_all_items () | Have a feature drop all their items on the tile they're on |
feature:delete_item (item, amt) | Delete an item from a feature's inventory |
feature:get_inventory () | Get every item in a feature's inventory: |
feature:has_item (item, sortBy, enchantments, level) | Check if a feature has an instance of an item ID |
feature:has_specific_item (item) | Check if a feature has a specific item |
feature:has_tag (tag) | Checks if a feature has a descriptive tag. |
feature:populate_items (map, room, forceDefault) | Populate items in a feature |
feature:modify_generated_item (item, map, room) | Modify an item generated by a feature |
feature:combust (skip_basic, source) | Checks a feature's combust() callback, if applicable, and then lights it on fire if applicable. |
feature:apply_cold (source) | Checks a feature's apply_cold() callback, if applicable, or its cold_feature flag, if applicable |
feature:apply_heat (source) | Checks a feature's apply_heat() callback, if applicable, or its heat_feature flag, if applicable |
Methods
- feature:init (feature_type, info, x, y)
-
Initiates a feature. Don't call this explicitly, it's called when you create a new feature using Feature('featureID').
Parameters:
- feature_type The ID of the feature you'd like to create
- info An argument to pass to the feature's new() function, if applicable (optional)
- x The x-coordinate (optional, will be set when it is added to the map)
- y The y-coordinate (optional, will be set when it is added to the map)
Returns:
-
The feature itself.
- feature:get_name (full)
-
Returns the name of the feature.
Parameters:
- full Boolean. Whether to return the name in uppercase and without an article.
Returns:
-
String. The name.
- feature:get_description ()
-
Returns the description of the feature, and descriptive lines noting what you can do with it.
Returns:
-
String. The description.
- feature:can_enter (enterer, fromX, fromY)
-
Calls the can_enter() function of a feature, if it has one.
Parameters:
- enterer Creature. The creature entering the feature's tile.
- fromX Number. The x-coordinate the creature is coming from
- fromY Number. The y-coordinate the creature is coming from
Returns:
-
Boolean. Whether or not the creature was allowed to enter.
- feature:enter (enterer, fromX, fromY)
-
Calls the enter() function of a feature, if it has one.
Parameters:
- enterer Creature. The creature entering the feature's tile.
- fromX Number. The x-coordinate the creature is coming from
- fromY Number. The y-coordinate the creature is coming from
Returns:
-
Boolean. Whether or not the creature was allowed to enter.
- feature:push (pusher)
-
Pushes a feature, if it's pushable. This also calls the push() callback of a feature, if applicable.
Parameters:
- pusher Creature. The creature pushing the feature. This will be used to determine where it is being pushed to.
Returns:
-
Boolean. Whether or not the push went through.
- feature:moveTo (x, y, noTween)
-
Moves a feature to a new location.
Parameters:
- x Number. The x-coordinate to move to.
- y Number. The y-coordinate to move to.
- noTween Boolean. If true, no tweening animation will be used. (optional)
Returns:
-
Boolean. Whether or not the move happened.
- feature:damage (amt, source, damage_type, force, armor_piercing)
-
Damages a feature, destroying it if it has HP and the damage done was more than its HP.
Parameters:
- amt Number. How much damage is being done.
- source Entity. What is damaging the feature.
- damage_type String. The damage type. (optional)
- force Boolean. Whether or not to ignore the feature's damage() callback (optional)
- armor_piercing True/False, or Number. If set to true, it ignores all armor. If set to a number, ignores that much armor. (optional)
Returns:
-
Number. The final damage that was done.
- feature:calculate_damage_received (amt, damage_type, armor_piercing, ignoreWeakness)
-
Calculates the damage amount a feature would receive based on damage types, weaknesses, armor, etc
Parameters:
- amt Number. The damage to deal.
- damage_type String. The damage type of the attack. (optional)
- armor_piercing True/False, or Number. If set to true, it ignores all armor. If set to a number, ignores that much armor. (optional)
- ignoreWeakness Boolean. If true, don't apply weakness (optional)
Returns:
-
Number. The final damage done.
- feature:destroy (source, damage_type)
-
Destroy a feature. This is different from Feature:delete() in that it calls the destroy() callback and drops any items in its inventory
Parameters:
- source Entity. The source of the damage (optional)
- damage_type String. The damage type (optional)
- feature:delete (map)
-
Delete a feature from the map
Parameters:
- map The map that the feature is on. If blank, defaults to the current map. (optional)
- feature:refresh_image_name (map)
-
Refresh the image name of a feature.
Used for features that look different if they're next to each other, like water, when its surrounding has changed.
Parameters:
- map
Returns:
-
Boolean. Whether the image name was refreshed or not
- feature:is_hazardous_for (ctype)
-
Checks if a feature is hazardous for a certain creature type.
Parameters:
- ctype String. The creature type we're checking for. If blank, just checks if it's generally hazardous. (optional)
Returns:
-
Boolean. Whether or not the feature is hazardous.
- feature:action (activator, actionID, args.)
-
Perform a feature's action() callback, if applicable.
Parameters:
- activator Creature. The creature activating the feature.
- actionID Text. The ID of the action (optional, only if a feature has multiple actions available).
- args. Anything. Other arguments to pass to the action (optional)
- feature:action_requires (activator, actionID)
-
Check if a feature's action's requirements are met
Parameters:
- activator Creature. The creature activating the feature.
- actionID Text. The ID of the action (optional, only if a feature has multiple actions available).
- feature:take_item (taker, item)
-
Perform a feature's take_item() callback, if applicable.
Parameters:
- taker Creature. The creature taking the item from the feature
- item Item. The item being taken
- feature:cleanup (map)
-
Perform a feature's cleanup() callback, if applicable.
Parameters:
- map Map. The map the feature is on
- feature:give_item (item)
-
Transfer an item to a feature's inventory
Parameters:
- item Item. The item to give.
- feature:drop_item (item)
-
Have a feature "drop" an item it contains on to the tile it's on
Parameters:
- item Item. The item to drop
- feature:drop_all_items ()
- Have a feature drop all their items on the tile they're on
- feature:delete_item (item, amt)
-
Delete an item from a feature's inventory
Parameters:
- item Item. The item to remove
- amt Number. The amount of the item to remove, if the item is stackable. Defaults to 1.
- feature:get_inventory ()
- Get every item in a feature's inventory:
- feature:has_item (item, sortBy, enchantments, level)
-
Check if a feature has an instance of an item ID
Parameters:
- item String. The item ID to check for
- sortBy Text. What the "sortBy" value you're checking is (optional)
- enchantments Table. The table of echantments to match (optional)
- level Number. The level of the item (optional)
Returns:
- either Boolean or Item. False, or the specific item they have in their inventory
- either nil or Number. The index of the item in the inventory
- either nil or Number. The amount of the item the player has
- feature:has_specific_item (item)
-
Check if a feature has a specific item
Parameters:
- item Item. The item to check for
Returns:
- either Boolean or Item. False, or the specific item they have in their inventory
- either nil or Number. The index of the item in the inventory
- either nil or Number. The amount of the item the feature has
- feature:has_tag (tag)
-
Checks if a feature has a descriptive tag.
Parameters:
- tag String. The tag to check for
Returns:
-
Boolean. Whether or not it has the tag.
- feature:populate_items (map, room, forceDefault)
-
Populate items in a feature
Parameters:
- map Map. The map the feature is in.
- room Room. The room the feature is in.
- forceDefault Boolean. If true, don't use any custom populate_items code
- feature:modify_generated_item (item, map, room)
-
Modify an item generated by a feature
Parameters:
- item Item. The item to modify.
- map Map. The map the feature is in.
- room Room. The room the feature is in.
- feature:combust (skip_basic, source)
-
Checks a feature's combust() callback, if applicable, and then lights it on fire if applicable.
Parameters:
- skip_basic Boolean. Whether to skip the combust() callback and just go ahead and light the fire. (optional)
- source Entity. The cause of the combustion
- feature:apply_cold (source)
-
Checks a feature's apply_cold() callback, if applicable, or its cold_feature flag, if applicable
Parameters:
- source Entity. The cause of the freezing
- feature:apply_heat (source)
-
Checks a feature's apply_heat() callback, if applicable, or its heat_feature flag, if applicable
Parameters:
- source Entity. The cause of the melting