Kitcoon Nametag
Based on game build 714014 | Last updated: 2026-03-05
Overview
The kitcoon_nametag prefab is a single-use inventory item used to rename Kitcoons. It integrates with the writeable, useabletargeteditem, and named components to provide a structured naming workflow: when used on a valid Kitcoon target, it opens a writeable UI, and upon accepting the entered name, the target Kitcoon is renamed. It is designed for one-time use (remove_after_write = true) and enforces distance and tag-based validation.
Usage example
local inst = CreateEntity()
inst:AddComponent("inventoryitem")
inst:AddComponent("useabletargeteditem")
inst:AddComponent("writeable")
inst.components.useabletargeteditem:SetOnUseFn(function(inst, target, doer)
-- Custom use logic, e.g., open writeable UI and rename target
end)
inst.components.writeable:SetOnWrittenFn(function(inst, new_name, writer)
if target.components.named then
target.components.named:SetName(new_name, writer)
end
end)
Dependencies & tags
Components used:
writeable— manages writing UI and text inputuseabletargeteditem— handles targeting logic and use eventsinventoryitem— enables inventory behaviorinspectable— (master-only) allows inspection
Tags:
kitcoon— checked on target viaIsKitcoonwriteable— added/removed dynamically viaSetDefaultWriteable(false); no static tags assigned
Properties
No public properties.
Main functions
OnUseOnKitcoon(inst, target, doer)
- Description: Called when the nametag is used on a target entity. Sets up naming session: begins writing, stops target's movement, marks target as being named, and listens for the target's removal to cleanly end the session.
- Parameters:
inst(Entity) — the nametag instancetarget(Entity) — the entity being named (must passIsKitcoonvalidation)doer(Entity) — the player using the item
- Returns:
true - Error states: Silent failure if
writeableorlocomotorcomponents are missing.
OnNamedByWriteable(inst, new_name, writer)
- Description: invoked when writing ends successfully. Applies the entered name to the
naming_targetvia itsnamedcomponent. - Parameters:
inst(Entity) — the nametag instancenew_name(string ornil) — the text entered by the playerwriter(Entity ornil) — the player who wrote the name
- Returns: Nothing
- Error states: No effect if
new_nameisnil,naming_targetis invalid, or the target lacks anamedcomponent.
OnWritingEnded(inst)
- Description: Cleans up the naming session when writing ends (successfully or canceled). Clears naming target state, removes event listeners, and stops usage state.
- Parameters:
inst(Entity) — the nametag instance
- Returns: Nothing
IsKitcoon(inst, target, doer)
- Description: Validation callback for
useabletargeteditem. Ensures the target has the"kitcoon"tag. - Parameters:
inst(Entity) — the nametag instancetarget(Entity) — candidate target entitydoer(Entity) — the player attempting to use the item
- Returns:
trueiftarget:HasTag("kitcoon"), otherwisefalse
Events & listeners
- Listens to:
onremoveonnaming_target— triggers cleanup viainst.onrmeove_naming_target(defined on first use) to cancel naming if the target is removed
- Pushes: None directly; delegates event-driven behavior to connected components (
writeable,useabletargeteditem).