Skip to main content

View as Markdown · AI documentation index

Clock

Game clock module for the react-text-game engine.

Provides in-fiction time that is independent of wall-clock time, persists with the save, and by default only advances when the game advances it.

Example​

import { Clock, HOUR, MINUTE } from '@react-text-game/core/clock';
import { useGameTime } from '@react-text-game/core';

// Advance time from an action handler.
Clock.advance(30 * MINUTE);

// Read it anywhere.
const inGameDate = new Date(Clock.now());

// Render it reactively.
function ClockDisplay() {
const now = useGameTime();
return <span>{new Date(now).toLocaleTimeString()}</span>;
}

Classes​

Type Aliases​

Variables​

Functions​