Two things, and the second one matters more than it looks:
main.lua and see what it prints.That is the whole requirement for Unit 1. There are four ways to get there and none of them is more correct than the others — pick by what your machine lets you do.
Unit 2 is different and needs LÖVE instead. That install is covered on Activity 2.1, when you get there. Nothing on this page expires when you reach it.
Do this before installing anything. Lua may already be present, and this one line works in every environment on this page — installed or in a browser tab.
print(_VERSION)Lua 5.4If it says Lua 5.4, you are done. Skip to the bottom of this page and start Activity 1.1.
If it says Lua 5.5, read the note on versions below — you can still work, you just need to know about two figures that will not match. If it says Lua 5.1, that is LuaJIT, which is what LÖVE runs; it is fine for most of Unit 1 but is not what the outputs here were written against.
| Route | Use it when | Installs anything? |
|---|---|---|
| 1 — winget | Windows, and you can install software | Yes, one command |
| 2 — portable Windows | Windows with no admin rights | A folder, no installer |
| 3 — macOS | A Mac | Yes, via Homebrew |
| 4 — browser | Chromebook, locked-down machine, or you just want to start now | Nothing at all |
Windows ships a package manager called winget. Open Terminal or PowerShell from the Start menu and run:
winget install DEVCOM.LuaThat installs Lua 5.4.6, which is exactly the version this course was written against, and puts the lua command on your path so it works from any folder. Close and reopen your terminal afterwards, then check:
lua -vLua 5.4.6 Copyright (C) 1994-2023 Lua.org, PUC-RioIf winget refuses because you are not an administrator, that is a normal thing to happen on a school machine and not something you did wrong. Use Route 2 or Route 4 instead.
Same Lua, no installer. Download Lua-5.4.6-win64.zip from the cmake-lua releases page — it is the same build winget hands you, just as a folder.
C:\Lua is a good choice; your Documents folder works too.bin folder intact. lua.exe needs lua54.dll sitting next to it. Copying just the .exe out on its own will not run.C:\Lua\bin\lua.exe main.luaSearch the Start menu for environment variables and choose Edit environment variables for your account — the for your account one. That version edits only your own settings and does not need an administrator. Select Path, choose Edit, add C:\Lua\bin, then reopen your terminal.
After that, plain lua main.lua works and you can ignore the long path for the rest of the course.
With Homebrew installed:
brew install lua@5.4Ask for lua@5.4, not plain lua. Plain brew install lua now gives you Lua 5.5, which is the version with the two differences described below.
There is one annoyance and it is worth knowing about rather than being surprised by: Homebrew does not put this one on your path, because it keeps older versions separate on purpose. Add it yourself:
export PATH="/opt/homebrew/opt/lua@5.4/bin:$PATH"Then check with lua -v. If it still reports 5.5, the line above is not being read — make sure you added it to ~/.zshrc and opened a new terminal window.
This is the right answer on a Chromebook, on a school machine that will not let you install anything, and any time you would rather start writing Lua in the next thirty seconds than read installation instructions.
Open onecompiler.com/lua, delete the sample code, and type yours. It runs Lua 5.4, it has an input box for the few activities that read from you, and there is nothing to set up.
Run the version check first anyway. Any online tool can change what it runs without telling you, and print(_VERSION) takes one second.
Activity 1.12 uses two files — a module called bay.lua and a main.lua that pulls it in with require("bay"). A single-box editor has nowhere to put the second file.
You can still do the activity, and the trick is real Lua rather than a workaround that dodges the lesson. Paste the module into a package.preload entry above your main code, and require finds it there instead of on disk:
package.preload["bay"] = function() -- everything that would have been in bay.lua local bay = {} bay.capacity = 6 local docked = 0 function bay.dock(count) docked = math.min(bay.capacity, docked + count) return docked end function bay.status() return docked .. " of " .. bay.capacity end return bayend
-- main.lua starts here, unchangedlocal bay = require("bay")print("Capacity:", bay.capacity)The output is identical to the two-file version, and the activity's point survives: the module is still a table you build privately and return, and docked is still invisible from outside it.
Chromebooks can run a real Linux terminal. If yours has it enabled, you get the full experience instead:
sudo apt updatesudo apt install lua5.4Lua 5.5 runs everything in this course correctly. It just prints two things differently, and both appear in figures you are meant to compare your own output against. Knowing about them costs less than chasing a bug that is not there.
print(math.sqrt(2))| Version | Prints |
|---|---|
| 5.4 — what Activity 1.4 shows | 1.4142135623731 |
| 5.5 | 1.4142135623730951 |
The other one is in Activity 1.6, where a loop counts 0 to 1 in steps of 0.25. Lua 5.4 prints the ends as 0 and 1; 5.5 prints 0.0 and 1.0.
Every other number in the course is identical on both. Those two are the whole list, so if something else does not match, it is worth reading your code rather than blaming your Lua.
Routes 1 to 3 leave you needing somewhere to write files. Any editor works — the rest of the course assumes VS Code because it has a terminal built in, which saves flipping between windows every time you run something.
Ctrl+` — that is the backtick key, above Tab. It opens already pointed at your folder.main.lua and run it:lua main.luaThe Lua extension by sumneko is worth adding for highlighting and error squiggles. It does not include Lua itself, so it is not a substitute for any route above.
print(_VERSION) in it runs and prints a version.That is enough. Activity 1.1 starts with one line of code and builds from there.