pages.onChange doesn't work

I’m trying to use the onChange callback from pages (Preset Lua extension | Electra One Documentation), but it doesn’t seem to be working.

I’d expect it to work at least on the [Lua] Page API preset from here Electra One App, but even that one doesn’t print the page changed: line to the debugger.

Is it working for anybody? I’m on v3.3.2 with the mkII.

Try putting this:

events.subscribe(PAGES | POTS)

at the top of your LUA script.

You need to subscribe to events so the E1 OS knows to send them to you.

(might not need POTS now, but maybe later)

1 Like

Thanks a lot @oldgearguy! Subscribing indeed makes the callback work over here.

@martin The documentation about pages (Preset Lua extension | Electra One Documentation) doesn’t mention that you have to subscribe to the event first. It’s only explained much further down in the Lua doc under the events section (Preset Lua extension | Electra One Documentation). Maybe it’d be a good idea to mention that it’s vital to subscribe for the pages callback to work. Other callbacks like midi.onSysex work without subscribing, so this is a bit surprising and should be covered in the manual in the relevant section. I’d recommend something like:

pages.onChange (newPageId, oldPageId)

A callback function that is called when a page is changed.

newPageId - integer, a numeric identifier of the new page (1 .. 12). id attribute from the preset.
oldPageId - integer, a numeric identifier of the old page (1 .. 12). id attribute from the preset

Note: For the callback to work, you’ll need to subscribe to the PAGES event as explained in the events section (Preset Lua extension | Electra One Documentation)

I originally found all of it under the “Events” heading farther down the docs.