Programming basics

The programming language of Retro Gadgets is Lua.

To start programming a Gadget you need at least one CPU. When you drag a CPU to the board a new Lua source code file is created and bound to the CPU. Now you can start to write your first code!


  1. Add a CPU to your Gadget’s board
  1. Grab the MultiTool handle on the left side of the screen
  1. Go to Gadget > Assets
  1. Look for the source code file for the CPU. It should be named something like “CPU0.lua”
  1. Select the file
  1. Press the edit button on the left side of the multitool screen.
  1. Now you’re ready to code!

Here is the suggested basic structure of your source code

-- Basic source file template
-- INIT AREA: Anything you put here will be executed first
log("Hello world!")

-- This function will be called each time tick. 
function update()
-- Place here code to be executed each time tick


Here are some basic blocks of code:

Light up a led

-- the basic space "gdt." gives you access to the gadget's components
-- "led0" is the name of the LED. typing "gdt." the autocomplete will 
-- help you suggest the names of all available components 
gdt.led0.State = true

Check the status of a button

-- "buttonname" is the actual name of the button component
if gdt.buttonname.ButtonState == true then log("button pressed") end

To check a button continuously you have to place the check inside the update function:

function update()
	if gdt.buttonname.ButtonState == true then log("button pressed") end

And, if you want to light up a led while the button is pressed

function update()
	gdt.ledname.State = gdt.buttonname.ButtonState