Skip to content

MoonLiveService

Source: MoonLiveService.h

MoonLiveService

class MoonLiveService
src/core/services/MoonLiveService.h:36

Inherits: MoonModule

A scripted service: the input twin of a scripted effect, and the flexible half of input.

The compiled services are lists of mappings, wrong for anything with a condition in it. A script holds the edge state a row cannot, and decides between outcomes. So a sensor nobody wrote a module for needs a datasheet and eight lines, not a release.

MoonLiveService card

Public Methods

virtual inline ModuleRole role() const override : A service, so the container accepts it as a child.

virtual inline void defineControls() override : Declare the script's name, then whatever controls the script itself declared.

virtual inline bool affectsPrepare(const char * controlName) const override : Only naming a different script recompiles, a value change updating a byte the tick reads.

virtual inline void prepare() override : Compile the script where the file has changed, then surface what it declares.

virtual inline void tick20ms() override : The service moment, where a press and a sensor reading both live.

virtual inline void release() override : Free the compiled block and forget it, so re-enabling rebuilds from the file.

inline void setScript(const char * name) : Point the module at a script, which the next build compiles, as a UI edit would.

More info

The same relationship effects already have

A compiled effect and a scripted one are interchangeable, and so are the input services. The engine is identical, so a script author already knows the language. Factory-registered like the others: added under the container, then pointed at a file.

It runs on the slow tick

A contact closes for tens of milliseconds and a sensor answers at its own rate. The render rate would sample thousands of times to learn the same thing. It also means a heavy script costs its own tick rather than stuttering the lights.

What it reaches: the pins for hardware, and the control surface for output. That is the two-step model the mapping rows use, so a script drives the surface alone. A script therefore cannot rewrite a driver's pins by naming it.