Luawe
The scripting language of the Wayfarer Engine. With it, a Pathfinder level can do things no node can: build itself, keep score, change with every try, or be a small game of its own.
-- Every fourth beat, the camera gives a kick.
level.beat:connect(function(beat)
if beat % 4 == 0 then
camera:effect("pulse", 0.5, 0.4)
end
end)What it is
A script is a text that tells a level what to do while it is played. It is written in Luawe ("loo-ah-way": Lua for the Wayfarer Engine), a small language made for this game. If you have written Lua before, you will feel at home, and one page lists what is different.
Scripts are the second way to give a level logic. The first is the nodes of the Logic tab, and they stay the best place to start: nodes can do most of what a level needs, and they are easier to learn and to read. Reach for a script when the nodes run out, for example when something has to be worked out, repeated many times, or made while the level runs.
Both ways work together. A script can read and set the variables the nodes use, and they both see the same things in the level.
Turning it on
Scripted logic is off until you ask for it.
- Open a level in the editor and go to the Logic tab.
- Click Scripted logic, at the right of the tab's row, and confirm.
- The tab now has two sides: Nodes and Scripts. Scripts are written on the second.
On the Scripts side the files are on the left, the script in the middle and the script output on the right. As you type, a list offers what could come next, a word under the mouse says what it means, and a mistake is marked on its line.
Where to start
- Your first script takes ten minutes and ends with something moving.
- The pages under The language teach Luawe itself, from values to functions.
- The pages under In the level show what a script can do there: things, the cube, the camera, waiting, events.
- Four scripts to learn from are worth reading line by line. Three of them are in the editor too, under Try an example.
- The reference lists everything a script can use.
Where scripts live
Every script is a file of its own in the level's folder, in a folder called scripts: a script named door is scripts/door.luawe. They are saved with the level and travel with it.
The files are plain text, so they can be opened in any text editor. The editor in the game is the place made for it, though: it knows the language, and it reads a file again when another program has changed it.
Safe by design
A script lives inside the level being played and nowhere else. There is nothing in Luawe for reading or writing files, for the internet, for other levels, for the game's settings or for anything else on a computer, so a level you download cannot use its scripts to do harm. It also cannot freeze the game: a script that never stops is stopped. Limits and safety has the details.