Skip to content

1.3 Script registration

Udo edited this page Aug 16, 2024 · 4 revisions

What does "registration" mean?

All scripts found on the transmitter must be "registered" at startup and therefore made known to the operating system. This happens regardless of which scripts are actually used in the respective model. After completing the boot process, the transmitter essentially has a "catalog" of available scripts of the respective types and can then present selection lists during operation.

Each Lua script is divided into certain "modules", called handlers, which each cover specific tasks (e.g., background data processing, controlling/drawing the display, configuring widgets, reading or saving configurations, catching and evaluating events, etc.).

In any case, each script must define the so-called init handler so that the script is registered at transmitter startup.

During this process, it is also specified which "modules," or additional handlers, are used in the script. The method to register such a script is a "system function" and thus from the system class.

For example, a widget is declared with the method "system.registerWidget()." As a code snippet, here is a possible example of a complete init handler for a widget:

local function init()
system.registerWidget({key="Xample", name="Example", create=create, wakeup=wakeup, paint=paint})
end
  • key is the UNIQUE key for the script; it must not appear in any other script, regardless of type.
  • name is the name presented in a selection list.
  • create is the handler that is executed the first time the script is called and is assigned to the function of the same name "create." The handlers and their assigned functions often use the same name so you see the syntax create=create.
  • Accordingly, the background handler wakeup is defined.
  • And also the paint handler for graphical representations.

A detailed overview of the script-type-specific registration methods and parameters can be found in the online documentation or the Lua Reference Guide; sources will be listed later.

Clone this wiki locally