Waxed Plant Common
Based on game build 714014 | Last updated: 2026-03-07
Overview
This module provides factory functions to create and manage waxed plant prefabs—items that preserve a plant's visual and structural state when harvested with beeswax. It supports two distinct prefab types: waxed (the in-world plant that decomposes when worked) and dug_waxed (the inventory item used for replanting). The module handles animation blending, colour fading effects via colourtweener, save/load synchronization, and deploy logic. It relies heavily on workable, lootdropper, inspectable, deployable, and colourtweener components.
Usage example
-- Create a standard waxed plant prefab for "grass"
return Prefab("grass_waxed", CreateWaxedPlant({
prefab = "grass",
bank = "grass",
build = "grass",
anim = "idle",
action = "CHOP",
animset = {
idle = { anim = "idle" },
flower = { anim = "flower" },
},
getanim_fn = function(parent) return parent:GetCurrentAnimationName() end,
}))
Dependencies & tags
Components used: colourtweener, deployable, fuel, inspectable, inventoryitem, lootdropper, stackable, workable
Tags: Adds waxedplant to created entities.
Properties
No public properties—this is a utility module that returns factory functions, not a component with mutable instance state.
Main functions
CreateWaxedPlant(data)
- Description: Creates a prefab definition for a waxed in-world plant that can be worked (e.g., chopped or dug) to produce a replantable
dug_waxeditem or vanish. Acceptsdatawith mandatory fields likeprefab,bank,build,anim,action,animset, andgetanim_fn, plus optional customization hooks. - Parameters:
data(table) — Configuration object. See detailed comment block in source for full schema.
- Returns: A
Prefabconstructor function (suitable for return in aPrefabdefinition). - Error states: None—fails safely if referenced anims are invalid (logs a warning and returns
nilinternally during animation lookup).
CreateDugWaxedPlant(data)
- Description: Creates a prefab definition for the inventory item form of a waxed plant (the "dug" variant) intended for replanting via deployable interactions. Supports deployment with original plant state restored.
- Parameters:
data(table) — Configuration object withname,action,animset,getanim_fnrequired; optional fields includeprefab,bank,build,anim,floater,deployspacing.
- Returns: A
Prefabconstructor function. - Error states: None.
WaxPlant(plant, doer, waxitem)
- Description: Converts an existing plant entity into its waxed counterpart. Captures current animation, colour, scale, position, and build state, spawns a
waxedprefab, and applies visual fade-out effects. - Parameters:
plant(EntityRef) — The original plant entity to wax.doer(EntityRef, optional) — The entity performing the waxing action (e.g., player).waxitem(EntityRef, optional) — The waxing tool/item.
- Returns:
trueon success, otherwisefalse. On success, returns{waxed=entity, data=config}as extra return values. - Error states: Returns
falseif noprefab_waxedversion exists, or ifGetParentCurrentAnimationreturns an invalid animation name.
Configure(inst, data)
- Description: Applies saved visual and structural state (position, bank, build, scale, animation frame, colour, minimap icon, stump flags) to a new waxed plant instance. Invoked during instantiation or load.
- Parameters:
inst(EntityRef) — The waxed plant entity to configure.data(table) — State data (e.g., from save orWaxPlantresult).
- Returns: Nothing.
- Error states: Safely skips optional fields if missing or invalid.
SpawnWaxedFx(inst, pos)
- Description: Spawns the
beeswax_spray_fxeffect at a position and triggers a fade-to-dark animation usingcolourtweener. - Parameters:
inst(EntityRef) — The waxed plant entity (used for colour state).pos(Vector3) — Spawn position for the effect.
- Returns: The spawned
beeswax_spray_fxentity (ornil), provided for modding extensibility. - Error states: Returns
nilif effect prefab fails to spawn.
Events & listeners
- Pushes:
colourtweener_start,loot_prefab_spawned,on_loot_dropped(vialootdropperandworkable). - Listens to: None directly—relies on system-level events (
OnSave,OnLoad) attached toinst.