← All scene elements
SCENE ELEMENT / 05

Timer

Game time from plain text or structured JSON payloads.

LIVE WEB PLAYER

See it respond.

The same raylib runtime, compiled to WebAssembly. Load this example, inject MQTT messages and watch its published events.

Loading WebAssembly…
MQTT I/O
Waiting for runtime…

The browser requires a user action before the scene is loaded. Click Load demo scene first. MQTT is emulated and never leaves this page. Shaders are disabled in the web build; GPIO is hardware-only.

Text-based timer. It accepts plain display text or a JSON time payload and inherits text styling.

Configuration

FieldDescription
typetimer
time_fieldJSON property read from incoming time objects
valueInitial displayed time
font, size, color, alignSame as Text
mqtt_topicOptional direct source topic

Copy-and-paste JSON

json
{
  "type": "timer",
  "id": "main_timer",
  "pos": [100, 50],
  "font": "Technology.ttf",
  "size": 120,
  "color": "#FF4040FF",
  "time_field": "left",
  "value": "60:00",
  "layer": 2
}

MQTT

text
ergs/rpi01/update/main_timer             42:17
ergs/rpi01/cmd/main_timer/time           {"left":"42:17","elapsed":"17:43"}
ergs/rpi01/cmd/main_timer/color          #FFD700