Skip to main content

Last Update: 2023-07-06

Interaction Properties

API Version: 619045

Interaction properties define how entities in Don't Starve Together can be interacted with by players and other entities. These properties span across various components and create a consistent interaction system that handles actions like examining, picking up, attacking, and using items.

Core Interaction Properties

PropertyTypeDescription
clickableBooleanWhether the entity can be clicked on
inspectableBooleanWhether the entity can be examined
isactivatableBooleanWhether the entity can be activated
interactiveBooleanGeneral property for interactive status
useableBooleanWhether the entity can be used
useableitemBooleanWhether the item can be used on other entities
actionableBooleanWhether actions can be performed on the entity
attackwhenworkableBooleanWhether entity is attacked when right-clicked with a tool
inventoryitemBooleanWhether the entity can be picked up into inventory
unwrappableBooleanWhether the entity can be unwrapped
activatableBooleanWhether the entity can be turned on/off

Interaction Mechanisms

Interactions in Don't Starve Together work through a layered system of action priority and targeting:

Action Detection and Prioritization

When a player attempts to interact with an entity, the system follows these steps:

  1. Detect Possible Actions: Identify all possible actions based on:

    • The entity's components
    • The player's current state (items held, buffs, etc.)
    • Distance and positioning
  2. Action Prioritization: Sort actions based on priority values

    • Higher priority actions are shown first in the action wheel
    • Default actions are executed when right-clicking without a specific selection
  3. Action Execution: Perform the selected action through the component's handler

-- Example action handler
function SomeComponent:DoAction(act)
if act.action == ACTIONS.EXAMINE then
-- Handle examination
return true
elseif act.action == ACTIONS.PICKUP then
-- Handle pickup
return true
end
return false
end

Interaction Distance

Interactions have distance requirements:

  • Standard Interaction: Usually requires player to be within ~2-4 game units
  • Far Interaction: Some actions can work at longer ranges (e.g., examining)
  • Weapon Interaction: Based on weapon reach for attacks
  • Obstacle Checking: Line-of-sight checks for many interactions
-- Example distance check in component
function Component:TestAction(act, doer)
-- Check if interaction is physically possible
if act.action == ACTIONS.INTERACT and
doer:GetDistanceSqToInst(self.inst) <= self.interaction_distance_sq then
return true
end
return false
end

Action Types

Don't Starve Together has several standard action types:

ActionDescriptionCommon Components
EXAMINELook at and describe the entityInspectable
PICKUPPick up into inventoryInventoryitem
EATConsume for food valueEdible
CHOPCut down with an axeWorkable
MINEBreak with a pickaxeWorkable
HAMMERDismantle with a hammerWorkable
ATTACKDeal damageCombat
LIGHTLight on fireLighter
USEUse an itemUseableItem
DEPLOYPlace in the worldDeployable
HARVESTCollect resourcesHarvestable
COOKCook on fireCookable
REPAIRFix damaged itemRepairable
STOREPut into containerContainer
EQUIPWear or holdEquippable
OPENOpen containerContainer

Entity State and Interactions

Entity state affects available interactions:

  • Burning: Usually prevents standard interactions
  • Frozen: Many interactions disabled until thawed
  • Sleeping: Can enable special interactions
  • Building: Different interactions during construction
  • Damaged: May enable repair actions
  • Charged: Special interactions for electrical items

Several components define interaction properties:

ComponentKey Interaction Properties
Inspectabledescription, nameoverride, getstatus
Inventoryitemcangoincontainer, nobounce, canbepickedup
Workableworkable, workleft, workaction, onwork
UseableItemcanuse, onuse, inuse
Equippableequipslot, isequipped, onequip
Activatableinactive, inactive_name, active_name
Tradablegoldvalue, tradefor, acceptsstacks

Custom Interaction Handlers

Games and mods can define custom interaction handlers through component methods:

-- Example of custom interaction handler
function MyComponent:GetActionVerb(actiontype)
if actiontype == "EXAMINE" then
return "Analyze" -- Custom examine verb
elseif actiontype == "ACTIVATE" then
return self.activated and "Deactivate" or "Activate"
end
return nil -- Fall back to default
end

function MyComponent:CustomInteract(doer)
-- Custom interaction logic here
self.inst:PushEvent("interacted_with", {doer = doer})
return true
end

Controller Support

Interaction properties handle different input methods:

  • Mouse/Keyboard: Direct clicking on entities
  • Controller: Auto-targeting nearby entities
  • Action Wheel: When multiple actions are available
  • Action Prioritization: Determining which action to perform
-- Example controller targeting priority
function MyComponent:TranslateControllerUse()
if self.canuseontargets then
return "INTERACT" -- Higher priority for controller users
end
return nil
end

Common Interaction Events

Entities trigger several interaction-related events:

  • onactivate - When activated
  • ondeactivate - When deactivated
  • onpickup - When item is picked up
  • ondrop - When item is dropped
  • onputininventory - When placed in inventory
  • onremoved - When removed from inventory
  • onopen - When container is opened
  • onclose - When container is closed
  • onbuilt - When structure is built

See also