The Script Editor is our web-based editor and compiler, allowing to write plugins that will run on the Air Lab, utilizing its sensors, screen and input buttons. Moreover, through the ports on the back, external sensors and other components can be connected.
The Script Editor is based on Go (or Golang), a high-level C-like programming language. For complete documentation and syntax, please refer to The Go Programming Language Specification, or Go by Example for a hands-on introduction.
The Script Editor has built-in functions that allow quick access to its sensor and inputs, alongside drawing functions such as the Rect() or Line(), and the Beep() function to play sound through the built-in buzzer.
The full documentation can be found on the right-hand side of the Script Editor.
The Script Editor is part of the Studio and can be accessed from the menu on the left side in the Air Lab section.
Each newly created script contains a template script with a few basic lines of code that, when compiled, display the current temperature. The steps below show how to create a new script and run the template code:

The plugin should now be running and showing the current temperature.
In case the plugin did not launch automatically, you can access through the Lab and run it:

Let's break down the code inside of func main(), bit by bit:
package main
func main() {
for {
// clear screen
Clear(White);
// lookup info
tmp := Lookup(SensorTemperature)
// format string
str := Format("Temp: %.2f C", tmp)
// write string
Write(Width/2, Height/2-8, 0, Pixel16, Black, str, AlignCenter);
// wait for input or timeout after 1s
event := Yield(1000)
// handle escape
if event == Escape {
return
}
}
}
The logic of the script is wrapped by a for loop. In this loop, each line is executed one after the other, for as long as the plugin runs on the Air Lab.
Clear (White)
The Clear() function erases the Air Lab's screen at the beginning of each iteration, in preparation for new graphics to be drawn in the next code lines. The Clear() function takes one color argument: White, Black, or None.
tmp := Lookup(SensorTemperature)
The Lookup() function retrieves device information such as sensor readings, battery status, and storage data. It has one parameter, Info, which specifies what type of information to fetch. The full list of available arguments can be found under Info on the right-hand side of the Script Editor. In this case, the function looks up the temperature using the argument SensorTemperature.
The result of the Lookup() function is stored in a variable named tmp. In Go, variables are declared using the syntax name := value, where name is the variable's name and value is the data assigned to it. The := operator both declares and initializes the variable in one step.
str := Format("Temp: %.2f C", tmp)
This line formats the text using the Format() function and stores it in a variable. This function supports a limited set of format specifiers: %d, %x, %f, %.Nf, and %s. In this example, the string "Temp" is followed by %.2f, which formats the value as a floating-point number with two digits after the decimal point. The variable tmp provides the value that replaces the %.2f placeholder in the formatted string.
Write(Width/2, Height/2-8, 0, Pixel16, Black, str, AlignCenter)
The Write() function draws the text on the screen. It has seven parameters:
Width and divide it by 2 to render the text the middle of the screen on the X axis. The Height is divided by 2 minus 8 to render the text also in the middle on the Y axis. The figure 8 derives from the size of the font, which is 16 pixels tall.Pixel8, Pixel16 and Pixel24. The figure refers to the height of the font in pixels.White and Black.str which contains the formatted text and temperature reading.AlignCenter and AlignRight.Task: Change the
Yield()Timeout to 10000 and notice how the temperature updates only every 10 seconds.
event := Yield(1000)
This line creates a variable that stores the input event returned by Yield(). The function takes a single argument, a timeout in milliseconds, during which the script pauses and yields control back to the Air Lab's operating system.
If you omit the Yield() function, the script will run in an infinite loop without any pause, which can lead to high CPU usage and unresponsiveness. By including Yield(), you allow the Air Lab to manage resources effectively and respond to user inputs.
if event == Escape {
return
}
This bit checks whether the variable event equals the predefined input constant Escape (a press on the button of the Air Lab) if so, the function stops executing and returns, effectively exiting the plugin.
The full lists of the predefined input constants can be found in the documentation, under Event.
Additional sensors and other components can be connected through the Air Lab's extension ports, either via I2C or via the 2 GPIOs (General-propose input/output).
The GPIOs can be configured as analog, PWM, or digital I/O, using the pin configuration functions:
GPIOConfig() – Sets the specified pin as digital input or output.AnalogConfig() – Sets the specified pin as analog input.PWMConfig() – Sets the specified pin for PWM output.