Skip to content

Your first script

You need a CURIO LED that is powered on and claimed by your account, and a browser.

No panel yet? Everything on this page also works in the preview: press Run instead of Upload to panel and the script draws in the editor’s Preview card.

Go to CURIO Code and sign in. The editor opens with an example already loaded.

  • The Panel card on the right lists the panels on your account. Pick one and press Connect. The dot at the bottom left turns green when the editor is talking to it.
  • The Status card shows whether the panel is online and what happened to the last script you sent.

Replace the editor’s contents with this and press Upload to panel (or Ctrl+Enter, ⌘+Enter on a Mac):

function _draw()
gfx.cls(0, 0, 40) -- dark blue background
gfx.rectfill(8, 8, 16, 16, 255, 200, 40)
gfx.line(0, 63, 63, 0, 255, 255, 255)
end

The panel shows a yellow square and a white diagonal. The log on the right says the panel loaded the script.

What the three calls do:

  • gfx.cls(r, g, b) fills the whole panel with one colour.
  • gfx.rectfill(x, y, width, height, r, g, b) fills a rectangle.
  • gfx.line(x0, y0, x1, y1, r, g, b) draws a line.

Coordinates start at the top-left pixel, (0, 0). Colours are red, green and blue from 0 to 255.

_draw runs every frame, so anything that changes between frames animates. Keep the changing value in a variable and advance it in _update:

local x = 0
function _update(dt)
x = x + 20 * dt -- 20 pixels per second
if x > gfx.width() then x = -8 end
end
function _draw()
gfx.cls(0, 0, 40)
gfx.rectfill(math.floor(x), 28, 8, 8, 255, 200, 40)
end

dt is the time since the last frame, in seconds. Multiplying by it keeps the speed the same however fast the panel is drawing.

If a script has an error, the panel stops it and shows a small red square in the top-left corner on a black screen. The editor’s log and the Last script line show the Lua error with its line number:

"my_script" failed: [string "my_script"]:5: attempt to call a nil value (field 'rectfil')

Fix the line and upload again. Nothing needs to be reset.

The preview reports the same error, with the same line number, without a panel.

  • Scripts are not stored on the panel. After a power cycle it goes back to its built-in scene. Upload again to bring yours back.
  • The draft autosaves in your browser, so closing the tab does not lose your work.
  • The example menu at the top of the editor has scripts for everything in these docs.

Next: How a script runs.