.lmz — Event-driven | LMX

LMX // .LMZ

.lmzEvent-driven

Register on/emit handlers; reactive event-bus scripting.

  • Runs here
  • a .lmz file
  • free to run
WHAT IT IS

Why .lmz exists.

An event-bus language: declare on <event> do … end handlers and fire them with emit. (In the hosted runtime, blocking listen sources — stdin/serial/webhook — are skipped so a script always finishes; handlers and emits run fully.)

Runs here

This one runs in the browser sandbox with no account, and offline in the CLI.


A WORKED EXAMPLE

demo.lmz

The same script the engine test suite runs, so it cannot quietly stop working.

on beat do
  print("beat!")
end

on keyPress do
  print("key!")
end

emit beat
emit keyPress

listen do
  beat
  keyPress
end

# Example adapters:
# listen webhook 3000 /hook do
#   beat
# end
#
# listen serial "/dev/ttyUSB0" 9600 do
#   beat
# end
Run it

1 more example

LMZ serial-listener demo. Handlers fire on incoming lines; the live `listen serial` source is
# LMZ serial-listener demo. Handlers fire on incoming lines; the live `listen serial` source is
# shown at the bottom (skipped in the hosted runtime, which has no serial port).

on serialLine do
  print("serial:", payload)
end

on serialRandom do
  print("rand:", payload)
end

# Simulate a couple of incoming readings so the handlers fire when run headless:
emit serialLine "reading 25.4"
emit serialRandom "0.87"

# Live wiring (uncomment when running the CLI against a real device):
# listen serial "COM3" 115200 do
#   "*" => serialLine
#   "__random__" => serialRandom
# end

SYNTAX

The shape of it.

Straight from the interpreter catalogue — the same summary the editor shows as a placeholder.

on beat do
  print("beat!")
end

emit beat

NEXT

Where to take it.