Skip to main content

Beaverbadge

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

Overview

BeaverBadge is a UI widget that extends Badge to display the beaver (sanity) meter. It visually represents the current sanity level as a percentage and adjusts its arrow animation based on both the sanity value and whether a full moon is active. It is used in the HUD to provide visual feedback about the player’s sanity status, particularly for characters affected by sanity mechanics like the beaver.

Usage example

local beaverbadge = BeaverBadge(player)
player:AddChild(beaverbadge)
beaverbadge:SetPercent(player.components.sanity.current, player.components.sanity:GetMax())

Dependencies & tags

Components used: None identified
Tags: None identified

Properties

PropertyTypeDefault ValueDescription
sanityarrowUIAnimnilAnimated arrow child widget displayed under the badge number.
isfullmoonbooleanfalseCurrent full moon state, observed from TheWorld.state.isfullmoon.
valnumber100Current sanity percentage value.
arrowdirstringnilName of the currently playing arrow animation.

Main functions

UpdateArrow()

  • Description: Updates the arrow animation based on the current val and isfullmoon state. Plays "arrow_loop_decrease_most" if it’s a full moon and val > 0, otherwise plays "neutral".
  • Parameters: None.
  • Returns: Nothing.
  • Error states: Only updates the animation if the target animation differs from the current arrowdir.

SetPercent(val, max)

  • Description: Updates the displayed percentage and triggers arrow animation updates. Overrides Badge.SetPercent to maintain visual synchronization with sanity state.
  • Parameters:
    • val (number) — the current sanity value.
    • max (number) — the maximum sanity value (used by parent Badge logic).
  • Returns: Nothing.
  • Error states: None.

Events & listeners

  • Listens to: watch:isfullmoon — internal world state change callback (OnIsFullMoon) that updates isfullmoon and calls UpdateArrow().