Log inGet started
World

Skyclock: Day, Night and Weather Kit

README.md

galleryControls

The gallery scene's showcase control panel for worldClockKit. It docks on the left of the screen and drives the shared clock, weather and sky for everyone in the session.

local Controls = require("gallery.galleryControls")
Controls.show()          -- the panel
Controls.showDisplays()  -- all four clock displays, placed around it

What the panel holds:

  • A header with the time, day and season, and a collapse button (- / +). On a phone-sized screen it starts collapsed.
  • Time of day: the big readout, running/paused, a Pause/Resume button, and a day-coloured slider (00 to 24). Press or drag the slider to call Clock.setTime. Otherwise the slider follows the clock.
  • Day length: 1 / 3 / 10 / 20 minute buttons (Clock.setDayLength).
  • Sky look: one button per Sky.looks() (labels from skies). Weather: one button per Weather.list() (labels from weathers). The active ones are highlighted.
  • A hint line about the mouse.

Functions

  • Controls.show() shows the panel; calling it again re-shows it without making a second one. Controls.hide() removes it.
  • Controls.isShown(), and Controls.setCollapsed(bool?) (no argument flips it).
  • Controls.showDisplays() -> handles shows digital top-right, sun arc top-centre, analog bottom-right and minimal bottom-left, all clear of the panel. On a narrow screen the arc drops below the digital panel. Controls.hideDisplays() removes them.

Mouse in play mode

The default player controls (default inputMap, pointerLock = true) capture the cursor for mouse-look while the world runs. Esc releases it (the engine's pointer_lock_toggle), but a later click on the game view captures it again. Tab gives the panel the mouse properly: it calls Zin.pointer.unlock(), which drops the capture request so clicks stay with the panel. Tab again calls Zin.pointer.lock() and mouse-look comes back. The hint line on the panel shows the current state. In edit mode the panel takes clicks directly. Touch screens have no captured cursor, so a tap works anywhere.

Notes

  • Clicks reach the panel through ui.registerCallbackEnv("skyClockPanel", …). Callback ids are gc:* and element ids are scp_*.
  • Its state lives in modules.state(), so a hot-reload while editing (this file or a kit module it requires) keeps the panel up. The new run takes over and the old run's loop stops.