Wereeater
Based on game build 714014 | Last updated: 2026-03-03
Overview
Wereeater manages the progression toward transformation into the Werebeefalo (or Wereperson) state for entities with the wereplayer tag. It increments a counter when the entity consumes monstermeat, and triggers transformation once the counter reaches 2. It also handles resetting the counter over time and persists state across saves.
Usage example
local inst = CreateEntity()
inst:AddComponent("wereeater")
inst:AddTag("wereplayer")
-- Simulate eating monster meat
local food = SpawnPrefab("monstermeat")
inst.components.wereeater:EatMosterFood({ food = food })
Dependencies & tags
Components used: None identified
Tags: Checks wereplayer and wereitem; pushes event wereeaterchanged.
Properties
| Property | Type | Default Value | Description |
|---|---|---|---|
duration | number | TUNING.TOTAL_DAY_TIME / 2 | Time (in seconds) before monster meat counter decays by 1. |
monster_count | number | 0 | Current count of eaten monster meat items. |
forget_task | Task or nil | nil | Scheduled task that decrements monster_count after duration. |
forcetransformfn | function or nil | nil | Optional callback used to force transformation to a specific were-mode. |
Main functions
EatMosterFood(data)
- Description: Processes consumption of monster meat. Increments
monster_count, schedules decay, and triggers transformation if the count reaches 2. No effect ifinstalready has thewereplayertag. - Parameters:
data(table) - must containfood(a prefab instance) as a field. - Returns: Nothing.
- Error states: Early return if
instalready has tagwereplayer.
ResetFoodMemory()
- Description: Resets
monster_countto0and cancels any pending decay task. - Parameters: None.
- Returns: Nothing.
SetForceTransformFn(fn)
- Description: Sets the optional callback used by
ForceTransformToWere. - Parameters:
fn(function) - signature:(inst: Entity, mode: string?) -> nil. - Returns: Nothing.
ForceTransformToWere(mode)
- Description: Invokes the
forcetransformfncallback (if set) to transform the entity. - Parameters:
mode(string ornil) - the transformation mode to request (e.g.,"werebeefalo"), ornil. - Returns: Nothing.
OnSave()
- Description: Returns serialization data for saving. Returns
nilifmonster_countis0. - Parameters: None.
- Returns:
nilif not storing state.tablewithmonster_count(number) andtask_left(number, remaining time on decay task) otherwise.
OnLoad(data)
- Description: Restores state from saved data. Recreates the decay task if needed.
- Parameters:
data(table) - must containmonster_count(number) and optionallytask_left(number). - Returns: Nothing.
GetDebugString()
- Description: Returns a human-readable debug string for in-game debugging tools.
- Parameters: None.
- Returns: string - formatted as
"monster_count: X/4 (Y/Z)", whereXismonster_count,Yis remaining time on decay task (or0), andZisduration.
Events & listeners
- Listens to:
oneat- triggersEatMosterFood(data). - Pushes:
wereeaterchanged- fired aftermonster_countchanges, with payload:old(number) - previous count,new(number) - updated count,istransforming(boolean) - whether this change caused a transformation trigger.