Skip to main content

Mandrake Inactive

Based on game build 714014 | Last updated: 2026-03-05

Overview

mandrake_inactive defines the prefab data for both the raw and cooked mandrake plants. It establishes core inventory behavior, edibility, and sleep-inducing effects on consumption. The prefab uses shared logic via commonfn, with specialized behavior for raw and cooked states in rawfn and cookedfn respectively. It integrates with the edible, inventoryitem, cookable, stackable, freezable, pinnable, fossilizable, rider, sleeper, and grogginess components to determine which entities are affected when consumed.

Usage example

-- Example: Spawning and interacting with a raw mandrake
local inst = SpawnPrefab("mandrake")
inst.Transform:SetPosition(x, y, z)
inst:AddComponent("inventoryitem") -- ensure inventory integration if added manually
inst.components.edible.healthvalue -- returns TUNING.HEALING_HUGE for raw mandrake

Dependencies & tags

Components used: edible, inventoryitem, cookable, stackable, tradable, freezable, pinnable, fossilizable, rider, sleeper, grogginess, inspectable
Tags added: cookable (only for raw mandrake), meditem, smallitem, VEGGIE (via FOODTYPE)
Tags checked (for sleep target filtering): playerghost, FX, DECOR, INLIMBO, sleeper, player

Properties

PropertyTypeDefault ValueDescription
animstring"object" (raw), "cooked" (cooked)Animation state bank used in AnimState.
scrapbook_animstringSame as animUsed for scrapbook rendering.
maxsizenumberTUNING.STACK_SIZE_SMALLITEMMaximum stack size.
foodtypeFOODTYPE enumFOODTYPE.VEGGIEType of food, used for dietary logic.
healthvaluenumberTUNING.HEALING_HUGE (raw), TUNING.HEALING_SUPERHUGE (cooked)Health restored on consumption.
hungervaluenumberTUNING.CALORIES_HUGE (raw), TUNING.CALORIES_SUPERHUGE (cooked)Hunger restored on consumption.
productstring"cookedmandrake"Prefab name produced when cooked.

Main functions

commonfn(anim, cookable)

  • Description: Shared factory function that initializes core properties and components for both raw and cooked mandrake prefabs. Sets up transform, animstate, network sync, physics, inventory properties, and conditionally adds cookable component.
  • Parameters: anim (string) - animation name to play; cookable (boolean) - whether to add cookable component.
  • Returns: inst (Entity) — The initialized entity instance.
  • Error states: If executed on a non-master simulation (client), returns early after setting up non-networked properties.

rawfn()

  • Description: Factory function for the raw mandrake. Configures high healing/hunger restore and sets up the oneaten_raw handler to trigger area sleep.
  • Parameters: None.
  • Returns: inst (Entity) — The raw mandrake entity.
  • Error states: None.

cookedfn()

  • Description: Factory function for the cooked mandrake. Configures super-high healing/hunger restore and sets up the oneaten_cooked handler.
  • Parameters: None.
  • Returns: inst (Entity) — The cooked mandrake entity.
  • Error states: None.

doareasleep(inst, range, time)

  • Description: Finds and affects entities within a circular area around the mandrake with sleep/knockout logic. Filters out ghost, decor, floating FX, limbo, frozen, pinned, and fossilized entities.
  • Parameters: inst (Entity) — source of the effect; range (number) — radius of effect; time (number) — duration of sleep/knockout.
  • Returns: Nothing.
  • Error states: If a sleeper's mount exists, it receives a ridersleep event; players receive a yawn event. Entities without sleeper/grogginess components receive a generic knockedout event.

oneaten_raw(inst, eater)

  • Description: Callback triggered when raw mandrake is eaten. Plays a sound and schedules area sleep effect.
  • Parameters: inst (Entity) — the mandrake; eater (Entity) — the consumer.
  • Returns: Nothing.
  • Error states: None.

oneaten_cooked(inst, eater)

  • Description: Callback triggered when cooked mandrake is eaten. Plays a sound and schedules area sleep effect with a larger range.
  • Parameters: inst (Entity) — the mandrake; eater (Entity) — the consumer.
  • Returns: Nothing.
  • Error states: None.

oncooked(inst, cooker, chef)

  • Description: Callback triggered when raw mandrake is cooked. Plays a sound and schedules area sleep effect for the cook.
  • Parameters: inst (Entity) — the raw mandrake; cooker (Entity) — cooking device; chef (Entity) — the cooking player.
  • Returns: Nothing.
  • Error states: None.

Events & listeners

  • Listens to: None.
  • Pushes: yawn (to players), ridersleep (to mounts), knockedout (generic fallback).