In this chapter you write a real QuickApp — a dozen lines — and run it. It will count to three, tell you it's done, and stop. You don't need to understand every line yet; chapter 03 explains them. Right now the goal is simpler: write, press F5, see it live.
In VS Code, open your project folder (my-first-qa from chapter 01) and
create a new file: File → New File…, name it hello.lua, and type:
--%%name:hello
print("Hello from my first QuickApp")
local n = 0
setInterval(function()
n = n + 1
print("tick", n)
if n >= 3 then
print("done")
os.exit()
end
end, 400)
A few first impressions, without the theory:
-- are comments — notes for humans. The --%%
line at the top is the exception: that one is a note for flua
(--%%name:hello gives the QuickApp a name).print(...) writes a line to the log.setInterval(function() … end, 400) means: run this little block every
400 milliseconds. That's a timer — the heart of every QuickApp.if counts to three: after the third tick the QuickApp says done
and os.exit() ends it — and stops its timer with it.
os.exit()ends the QuickApp that called it. That's the same name real HC3 QuickApps use (there, every QuickApp is its own program — ending it is as simple as leaving a room). In these first experiments it's also what ends the run right there. Without it, flua would keep going while timers are pending — here, the 400 ms interval — and stop on its own once nothing is left to do.
Make sure hello.lua is the tab you're looking at, and press F5 (the
first time, choose Flua: Run Current File (Terminal) from the menu —
chapter 01's setup installed it). VS Code runs the file and shows the log
in its terminal panel:
🚀 flua 0.1.x (Lua 5.4, Python 3.x), mode offline (sim HC3, real network)
[04.10.2026][20:50:10][DEBUG ][hello5000]: Hello from my first QuickApp
[04.10.2026][20:50:10][DEBUG ][hello5000]: tick 1
[04.10.2026][20:50:11][DEBUG ][hello5000]: tick 2
[04.10.2026][20:50:11][DEBUG ][hello5000]: tick 3
[04.10.2026][20:50:11][DEBUG ][hello5000]: done
✅ You should see your QuickApp say hello, tick three times, and stop.
That's a complete QuickApp, running. The hello5000 at the start of each
line is the QuickApp's tag — its name and its id. The 5000 is the id
flua assigned it; on your real HC3 it would get the controller's next free
id.
What did F5 do? The launch configuration ran flua hello.lua for
you — and because your QuickApp doesn't declare a mode, flua ran it in its
default world: the simulated HC3, on your computer (online is opt-in;
chapter 06 shows how). It gave your QuickApp a home, started it, kept time
for it, and stopped when the program ended. Your real HC3 was never
involved — that's the whole point: experiment safely, then go live later.
If F5 complains that
fluawas not found: VS Code on some systems doesn't inherit the shell's PATH when started from the dock. Chapter 01's setup normally prevents this — the debugger configurations get the absolute path to flua written in (the F5 run configurations usepython -m flua, which only needs the right Python). If you wrote the configuration by hand (or reinstalled flua elsewhere), either re-runflua --tool setup, or restart VS Code from the terminal once — on macOS runopen -a "Visual Studio Code"in a terminal, on Windows/Linux startcodefrom one. If it says No module named 'flua' instead, VS Code is using a Python that doesn't have flua: open the Command Palette (Ctrl/Cmd+Shift+P), choose Python: Select Interpreter, and pick the one you installed flua into (chapter 01). You can always run the command by hand instead: open a terminal with Terminal → New Terminal and typeflua hello.lua— every F5 run in this tutorial does exactly that (python -m fluawith the file).
Programmers don't get code right the first time. They get it wrong fast
and let the computer tell them where. Try it: change local n = 0 to
local n = 0 + nn (a name that doesn't exist), save, and press F5
again:
Error: hello.lua:4: attempt to perform arithmetic on a nil value (global 'nn')
stack traceback:
.../flua/lua/init.lua: in function <...>
flua tells you the file, the line (4), and the problem: it tried to do
arithmetic on nn, which is nothing. ("Bootstrap" is flua-speak for
"while starting your QuickApp" — mistakes at startup show up like this,
mistakes later show up while the QuickApp is running.)
Change 0 + nn back to 0, save, F5. The loop from now on is exactly
this: change one thing, save, F5, read the log.
QuickApp files run again every time from scratch — there is no hidden state between runs. That makes experiments safe: nothing you break survives the next run.
For a really fast loop, flua can watch your file and restart it on every save — no F5 needed. This one is a terminal command (it has extra flags):
flua --api local --watch hello.lua
Now edit something — change "Hello from my first QuickApp" to
"Good evening, HC3" — and save. The log shows the QuickApp starting over
with the new text. Press Ctrl-C in the terminal to stop watching.
Next chapter: what a QuickApp is — and the Sunset Lamp gets its switch.