Plantresearchable
Based on game build 714014 | Last updated: 2026-03-03
Overview
PlantResearchable is a component that marks an entity as providing researchable plant data and facilitates the discovery of plant growth stages. It is typically attached to plant prefabs in the game world (e.g., Saplings, Carrot Plants, etc.) and allows entities like the Science Machine or Auto Animator to access and process their research metadata. When an entity with this component is interacted with for research, it notifies the_doer (typically a player or instrument) by pushing a learnplantstage event with plant name and stage information.
Usage example
local inst = CreateEntity()
inst:AddComponent("plantresearchable")
inst.components.plantresearchable:SetResearchFn(function(entity)
return { plant = "carrot", stage = 1 }
end)
Dependencies & tags
Components used: None identified
Tags: Adds plantresearchable
Properties
No public properties
Main functions
SetResearchFn(fn)
- Description: Assigns a custom function to generate research information about the plant. This function is called later to retrieve plant name and growth stage.
- Parameters:
fn(function) - a callback takingself.inst(the entity) and returning{ plant = string, stage = number }ornilif invalid. - Returns: Nothing.
GetResearchInfo()
- Description: Invokes the research function (if set) and returns the plant metadata.
- Parameters: None.
- Returns:
{ plant = string, stage = number }if successful;nilif no function is set or the function returnsnil. - Error states: May return
nilifreasearchinfofnis unassigned or yieldsnil.
IsRandomSeed()
- Description: Determines whether the plant is a random seed (i.e., its research info cannot be determined).
- Parameters: None.
- Returns:
trueifGetResearchInfo()returnsnil; otherwisefalse.
LearnPlant(doer)
- Description: Notifies the
doerentity that a plant stage has been learned, by pushing alearnplantstageevent. Typically called when the plant is examined by a research tool or machine. - Parameters:
doer(Entity) - the entity performing the research; must supportPushEvent. - Returns: Nothing.
- Error states: No-op if
GetResearchInfo()returnsnilorstageis invalid. Only proceeds if bothplantandstageare truthy.
Events & listeners
- Listens to: None identified
- Pushes:
learnplantstage— fired whenLearnPlant()is called with valid research info; payload is{ plant = string, stage = number }.