Erasablepaper
Overview
The ErasablePaper component provides erase functionality for an item: when triggered (typically by an eraser tool), it destroys the current item and spawns a new item (or stack thereof), such as converting a parchment into multiple papyrus sheets. It handles stack management, item spawning, and proper item delivery (to inventory or world drop).
Dependencies & Tags
- Requires
instto be an entity (typically an item) with optionalstackablecomponent. - Does not add or remove tags.
- Relies on external components:
inventory,inventoryitem, andstackable(if present on source or spawned item).
Properties
| Property | Type | Default Value | Description |
|---|---|---|---|
erased_prefab | string | "papyrus" | The prefab name of the item to spawn upon erasure. |
stacksize | number | 1 | The total number of erased items to produce (including the first). |
Main Functions
SetErasedPrefab(prefab)
- Description: Sets the prefab name of the item that will be spawned when erasure occurs. Validates the prefab exists.
- Parameters:
prefab(string) – A valid prefab name. Throws an assertion error if the prefab is not found.
SetStackSize(size)
- Description: Sets the total number of items to spawn during erasure (i.e., the stack size of the result).
- Parameters:
size(number) – An integer ≥ 1. Throws an assertion error if invalid.
DoErase(eraser, doer)
- Description: Performs the erasure: removes the current item and spawns
stacksizecopies of theerased_prefab. Handles both stackable and non-stackable results viaSpawnPrefabandGiveOrDropItem. Returns the first spawned item ornilon failure. - Parameters:
eraser(entity) – The tool/entity performing the erase (used for position and logic context).
doer(entity) – The entity attempting the erase (typically a player); used to determine item delivery.
Returns: First spawned item (if successful), ornilif spawning fails.
Events & Listeners
None. This component does not register event listeners or emit events.