Skip to main content

Chest Insanity

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

Overview

This scenario script defines the behavior of an "insanity chest" — a special chest that, when opened, spawns a ring of sanityrock prefabs around the player. The rocks behave differently depending on whether the player is currently sane: they animate as "raised and active" if the player is sane, otherwise as "lowered and inactive". The script uses chestfunctions to integrate with the chest trap system and ensures trap logic runs on chest load.

Usage example

The component is not added directly; it is used as a scenario callback by the game's scenario system. Typical integration looks like this:

-- In the scenario configuration (not shown here)
OnLoad = chest_insanity.OnLoad,

When a chest with this scenario is loaded and opened, the triggertrap function executes.

Dependencies & tags

Components used: finiteuses, sanity Tags: Checks sanityIsSane(); no tags added or removed.

Properties

No public properties.

Main functions

triggertrap(inst, scenariorunner, data)

  • Description: Executes the trap effect when the chest is opened. Spawns a ring of sanityrock prefabs around the chest at radius ~10 units. Each rock is hidden initially, then revealed sequentially with a delay. Rock animations depend on the player's sanity status.
  • Parameters:
    • inst (Entity) — The chest entity.
    • scenariorunner (ScenarioRunner) — Scenario runner instance.
    • data (table) — Contains player (Entity), the player who opened the chest.
  • Returns: Nothing.
  • Error states: If data.player or data.player.components.sanity is nil, the sanity check is skipped and rocks default to inactive animation.

Events & listeners

None.