Moondial
Based on game build 714014 | Last updated: 2026-03-06
Overview
The moondial is a structure prefab that visually indicates the current moon phase and enables gestalt transformation (via Abigail) under precise lunar conditions. It uses workable for dismantling, inspectable to report contextual status, and ghostgestalter to mediate player-initiated gestalt changes. Its behavior is tightly coupled to world state (moonphase, isalterawake) and uses the SGmoondial stategraph for animation.
Usage example
local inst = SpawnPrefab("moondial")
inst.Transform:SetPosition(x, y, z)
Dependencies & tags
Components used: workable, inspectable, lootdropper, ghostgestalter
Tags: Adds structure to the entity.
Properties
| Property | Type | Default Value | Description |
|---|---|---|---|
is_glassed | boolean | false (initially) | true when the Altar is active and the Moondial is "glassed"; controls loot and state transitions. |
icon | entity reference (globalmapicon) | nil (created lazily) | Map icon entity attached to track position for the minimap. |
Main functions
domutatefn(inst, doer)
- Description: Handles the mutagenesis logic for gestalt transformation when a player attempts to interact with the Moondial. Validates world context (not in caves), night time, ghost summon status, and moon phase. May change the ghost’s gestalt state as a side effect.
- Parameters:
inst(entity),doer(player entity performing the action). - Returns:
trueif mutation succeeds; otherwisefalse, reason(string reason code:"CAVE","NOGHOST","NOTNIGHT","NONEWMOON","NOFULLMOON"). - Error states: Returns
falseand a string reason if conditions are unmet. May mutateghost:ChangeToGestalt()state in-place on success.
getstatus(inst, viewer)
- Description: Returns a string key describing the Moondial’s current functional context from the viewer’s perspective.
- Parameters:
inst(the Moondial),viewer(the inspecting entity, typically a player). - Returns:
"CAVE","GLASSED","WEREBEAVER","GENERIC","NIGHT_NEW","NIGHT_FULL","NIGHT_WAX", or"NIGHT_WANE"based on world state and viewer. - Error states: Returns one of the known status keys under all world states; no
nilresult.
Events & listeners
- Listens to:
moonphase– viainst:WatchWorldState("moonphase", onmoonphasechagned)
isalterawake– viainst:WatchWorldState("isalterawake", onalterawake) - Pushes:
No explicitPushEventcalls in the provided code. - Callbacks:
onhammered– called byworkablewhen hammering completes; drops loot and removes the instance.
glassed_loot_fn– sets loot to"moonglass"whenis_glassedis true.