Hooks let you run callbacks when feces applies incoming replication data. They are set on the client-side feces instance and fire duringDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/NeonD00m/feces/llms.txt
Use this file to discover all available pages before exploring further.
feces:apply(). Each hook type corresponds to a different lifecycle event in the replication process — a new entity arriving, a component value changing, a component being removed, or an entity being destroyed.
added(callback)
Fires after a newly replicated entity has all of its components set. Use this to run initialization logic that depends on the entity already having its full component set for that replication frame.
Signature: feces:added(callback: (entity: LocalEntity) -> ())
added fires after all components in the packet have been applied to the entity. This means
that inside the callback you can safely read any component value that arrived in the same
packet — unlike changed, which fires before the new value is written.changed(callback)
Fires before a component’s new value is set on an entity. Use this to compare the incoming value against the previous state, or to react to a component being added for the first time.
Signature: feces:changed(callback: (entity: LocalEntity, component: Component, value: any) -> ())
Because
changed fires before the new value is written, you can call world:get(entity, component) inside the callback to read the previous value. You can also call
world:has(entity, component) to distinguish between a component being added for the first
time (false) versus an existing value being updated (true).removed(callback)
Fires before a component is removed from an entity. Use this to read the component’s last value or perform cleanup before the data disappears from the world.
Signature: feces:removed(callback: (entity: LocalEntity, component: Component) -> ())
Because
removed fires before the component is actually removed, world:get(entity, component)
still returns the previous value inside the callback. After apply completes, the component
will no longer exist on the entity.deleted(callback)
Fires before an entity is deleted from the world. Use this to read any remaining component values or run cleanup logic before the entity ceases to exist.
Signature: feces:deleted(callback: (entity: LocalEntity) -> ())
Hook Execution Order
Whenfeces:apply() processes a packet, hooks fire in this order for each entity and component:
deleted— fires for each entity marked for deletion (beforeworld:delete).added— fires for each entity that did not previously exist in the local world (after its components are set).removed— fires for each component being removed from an existing entity (beforeworld:remove).changed— fires for each component value being set or updated (beforeworld:set).