Skip to main content

Repairer

Overview

The Repairer component enables an entity to define and dynamically update its repair behavior by specifying values for different repair types (e.g., work, health, perish, finite uses). It manages associated tags on the entity to signal compatibility with various repair materials and actions. When repair values change or the repair material is updated, it automatically updates the relevant tags.

Dependencies & Tags

  • Tags added: "repairer" (always added on construction)
  • Dynamic tags added/removed based on repair material and values:
    • "work_" .. material
    • "health_" .. material
    • "freshen_" .. material
    • "finiteuses_" .. material
  • Dependencies: None explicitly added via AddComponent. Relies on standard inst functionality for tags.

Properties

PropertyTypeDefault ValueDescription
workrepairvaluenumber0Amount of work damage (e.g., tool durability) this entity repairs when using the configured material.
healthrepairvaluenumber0Absolute health restored when using the configured material.
healthrepairpercentnumber0Percentage of max health restored when using the configured material.
perishrepairpercentnumber0Percentage of perish (rot) reversed when using the configured material.
finiteusesrepairvaluenumber0Number of finite uses restored (e.g., for items like lanterns).
repairmaterialstring or nilnilName of the material used to perform repairs; e.g., "stone", "gold".

Main Functions

OnRemoveFromEntity()

  • Description: Cleanup method called when the component is removed from an entity. Removes all repair-related tags associated with the current repair material to prevent stale tags from persisting.
  • Parameters: None.

Events & Listeners

  • The component uses the Class framework’s automatic property watchers. When any of the following properties are modified externally, the corresponding callback functions are invoked:
    • workrepairvalue, healthrepairvalue, healthrepairpercent, perishrepairpercent, finiteusesrepairvalue → triggers onrepairvalue
    • repairmaterial → triggers onrepairmaterial
  • No manual inst:ListenForEvent or inst:PushEvent usage is present in this component.