Scrapbookable
Based on game build 714014 | Last updated: 2026-03-03
Overview
Scrapbookable is a lightweight component that allows an entity to be "taught" — a concept used in the scrapbook UI system to track learned recipes or knowledge entries. When an entity has this component, it can register a callback that executes upon teaching, typically used to unlock content in the scrapbook. It does not manage state persistence or UI rendering itself, but acts as a trigger point for external systems (e.g., the scrapbook screen) to invoke knowledge acquisition logic.
Usage example
local inst = CreateEntity()
inst:AddComponent("scrapbookable")
inst.components.scrapbookable:SetOnTeachFn(function(entity, doer)
print(entity.prefab .. " was taught by " .. (doer and doer.prefab or "unknown"))
-- Unlock recipe or update progress here
end)
-- Later, when player attempts to learn this entity:
inst.components.scrapbookable:Teach(player)
Dependencies & tags
Components used: None identified
Tags: None identified
Properties
No public properties
Main functions
SetOnTeachFn(fn)
- Description: Registers the callback function to be executed when the
Teachmethod is called. This function is typically used to unlock content (e.g., a recipe in the scrapbook). - Parameters:
fn(function) — a callback with signaturefunction(inst, doer), whereinstis the entity with theScrapbookablecomponent anddoeris the entity performing the teaching (e.g., the player). - Returns: Nothing.
- Error states: Accepts
nilas valid input; clearing any previously set function.
Teach(doer)
- Description: Executes the registered
onteachcallback (if one exists) and signals that this entity has been taught. Returnstrueto indicate success. - Parameters:
doer(Entity ornil) — the entity causing the teaching action (e.g., the player). - Returns:
true— always returned regardless of whether a callback was defined. - Error states: Does not fail; if no callback is set, it silently returns
trueafter no-op.
Events & listeners
None identified