Townportaltalisman
Based on game build 714014 | Last updated: 2026-03-07
Overview
townportaltalisman is a prefab that implements the Town Portal Talisman, an item used to link two Town Portals for fast travel. The component manages animation states, sound loops, sanity effects during teleport, and inventory interactions (e.g., auto-pickup exclusion, image changes). It integrates with teleporter, inventoryitem, inspectable, stackable, and talker components.
Usage example
local inst = CreateEntity()
inst.entity:AddTransform()
inst.entity:AddAnimState()
inst.entity:AddSoundEmitter()
inst.entity:AddNetwork()
MakeInventoryPhysics(inst)
inst:AddTag("townportaltalisman")
inst:AddTag("townportal")
inst:AddComponent("inventoryitem")
inst:AddComponent("teleporter")
inst:AddComponent("inspectable")
inst:AddComponent("stackable")
inst:ListenForEvent("linktownportals", function(inst, other) ... end)
Dependencies & tags
Components used: inventoryitem, teleporter, inspectable, stackable, talker, sanity, soundemitter, animstate, transform, network
Tags: Adds townportaltalisman, townportal, donotautopick (conditionally); removes donotautopick when unlinked.
Properties
No public properties are initialized directly on the component itself. Component properties are configured via inst.components.X assignments in the constructor.
Main functions
OnLinkTownPortals(inst, other)
- Description: Links the talisman to another portal (
other). Updates inventory image, animation, and sound state based on whetherotherisnil. Adds or removes thedonotautopicktag accordingly. - Parameters:
inst(Entity) — The talisman entity.
other(Entity ornil) — The target portal to link to. Ifnil, the talisman is unlinked. - Returns: Nothing.
- Error states: No explicit error handling; assumes valid
instand optionalother.
OnStartTeleporting(inst, doer)
- Description: Triggered when a player uses the talisman to teleport. Silences the player's speech and reduces their sanity; then destroys the talisman stack.
- Parameters:
inst(Entity) — The talisman entity.
doer(Entity) — The entity performing the teleport (typically a player). - Returns: Nothing.
- Error states: Silencing and sanity effects only apply if
doeris a player and has the corresponding components.
topocket(inst)
- Description: Resets animation tasks and updates animation upon placing the talisman in inventory (e.g., after linking or unlinking). Restores active or inactive loop based on
teleporterstatus. - Parameters:
inst(Entity) — The talisman entity. - Returns: Nothing.
- Error states: Returns early if no animation tasks are pending (
animtaskandonanimqueueoverare bothnil).
GetStatus(inst)
- Description: Returns
"ACTIVE"if the talisman is linked to a portal, otherwisenil. Used for theinspectablecomponent. - Parameters:
inst(Entity) — The talisman entity. - Returns:
"ACTIVE"(string) ornil.
Events & listeners
- Listens to:
linktownportals— TriggersOnLinkTownPortals.
onputininventory— Triggerstopocket.
exitlimbo— TriggersOnEntityWake.
enterlimbo— TriggersOnEntitySleep.
animqueueover— Used internally to chain animations (e.g., active_fall → inactive). - Pushes: None directly. Delegates events via
inst:PushEvent(...)in attached components (e.g.,imagechange,sanitydelta).