Weed Defs
Based on game build 714014 | Last updated: 2026-03-07
Overview
weed_defs.lua defines a central configuration table WEED_DEFS that stores data and callback functions for all weed plant types in the game. Each weed (forgetmelots, tillweed, firenettle, ivy) has associated metadata such as growth time distribution, spread parameters, seed drop chance, nutrient/moisture consumption, and custom behavior hooks (e.g., OnMakeFullFn, ondigup, masterpostinit). It also automatically populates registry and UI configuration fields for each weed type, ensuring consistent integration with the farm/plant system.
Usage example
-- Access the configuration for a specific weed
local forgetmelots_def = WEED_DEFS.weed_forgetmelots
print(forgetmelots_def.product) -- "forgetmelots"
-- Use grow times to schedule growth in a custom plant
local grow_times = MakeGrowTimes(2 * TUNING.TOTAL_DAY_TIME, 3 * TUNING.TOTAL_DAY_TIME, true)
-- Then assign to a growable's stagedata.time function
Dependencies & tags
Components used: growable, burnable, health, combat, playerprox, timer
Tags: Adds CLASSIFIED and weed_forgetmelots_respawner to respawner entities; dynamically adds/removes farm_plant_defender for ivy; sets custom trapdamage tag for firenettle.
Properties
| Property | Type | Default Value | Description |
|---|---|---|---|
prefab | string | nil (set in post-init loop) | Prefab name (e.g., "weed_forgetmelots"), auto-assigned. |
build | string | "weed_<name>" | Animation/build bank name. |
bank | string | "weed_<name>" | Animation bank name for this weed. |
grow_time | table | Generated by MakeGrowTimes | Table of min/max time ranges for each growth stage (small, med, full, bolting). |
spread | table | nil or weed-specific | Spread behavior configuration (e.g., stage, time_min, tilled_dist). |
seed_weight | number | TUNING.SEED_CHANCE_* | Weight used in seed drop probability. |
product | string or nil | "forgetmelots" etc. | Name of the item produced when harvested (nil for ivy). |
nutrient_consumption | table | {nutrient, nutrient, nutrient} | Nutrient consumption values per growth stage. |
moisture | table | {drink_rate = drink_*} | Moisture consumption configuration. |
extra_tags | table | {} or {"trapdamage"} | Additional tags added to the weed instance. |
prefab_deps | table | {} | Prefabs to ensure are loaded before use (e.g., "firenettle_toxin"). |
plantregistryinfo | table | Auto-generated | Data used by UI/registry to render plant growth stages. |
plantregistrywidget | string | "widgets/redux/weedplantpage" | Path to the UI widget for plant page. |
stage_netvar | function | net_tinybyte | Network replication type for stage. |
modded | boolean | nil | Set to true when a new entry is added via __newindex. |
sameweedtags | table | {weed} | Tags used to identify the same weed type (e.g., {weed_forgetmelots}). |
ondigup | function | nil (forgetmelots only) | Callback when the weed is dug up; handles respawning logic. |
OnMakeFullFn | function | nil or weed-specific | Callback when the weed reaches the full-grown stage. |
masterpostinit | function | nil (ivy only) | Hook to register custom event listeners after full init. |
OnTimerDoneFn | function | nil (tillweed only) | Callback for timer events (e.g., debris generation). |
Main functions
MakeGrowTimes(full_grow_min, full_grow_max, bolting)
- Description: Calculates relative growth durations for each stage (small, medium, full, optionally bolting) based on total min/max growth times. If
boltingis true, all stages include a "bolting" phase after full. - Parameters:
full_grow_min(number) – Minimum total days for full growth.full_grow_max(number) – Maximum total days for full growth.bolting(boolean) – Whether to include a bolting stage.
- Returns: Table
{ small = [min, max], med = [min, max], full = [min, max], bolting = [min, max] }or{ small, med }if not bolting. Times are expressed in days. - Error states: None. Values are clamped to valid ranges via multiplication.
ForgetMeLotsSpreadChanceMult(inst, chance, luck)
- Description: Modifies the respawning chance for forgetmelots based on player luck. Used during
ondigup. - Parameters:
chance(number) – Base chance.luck(number) – Player's luck value (negative or positive).
- Returns: Modified chance (number). If luck < 0, chance increases; if luck > 0, chance decreases via a reciprocal formula.
- Error states: Returns
chanceunchanged ifluck == 0.
SpawnSnare(inst, x, z, r, num, target)
- Description: Spawns ivy snare traps in a circle around a target. Used during the
defend_farm_plantevent. - Parameters:
inst(entity) – The ivy plant instance.x/z(numbers) – Center coordinates for snare placement.r(number) – Radius of the snare circle.num(number) – Number of snares to spawn (6 or 12).target(entity) – Target being snared.
- Returns: Boolean –
trueif at least one snare was placed, otherwisefalse. - Error states: Skips placement if the world geometry (
TheWorld.Map) deems the point impassable or near a hole.
Events & listeners
- Listens to:
defend_farm_plant(ivy only, viamasterpostinit) – triggers snare deployment and damage logic. - Pushes:
snared(ivy only, duringdosnaredamage) – notifies entities they are snared withANNOUNCE_SNARED_IVYlocalization key.