typestar

The script shape in Lua

The smallest Lua: locals, print, and string.format.

-- A script runs top to bottom; print writes a line.
local dungeon = "The Sunken Crypt"
local floors = 5

print("Now entering " .. dungeon)
print("Floors to clear:", floors)
print(string.format("Rooms if all full: %d", floors * 8))

How it works

  1. A script runs top to bottom; no main function exists.
  2. .. concatenates; print takes several arguments with tabs.
  3. string.format does the printf work with %d and %s.

Keywords and builtins used here

The run, in numbers

Lines
7
Characters to type
231
Tokens
39
Three-star pace
75 tpm

At the three-star pace of 75 tokens a minute, this run takes about 31 seconds.

Type this snippet

Step 1 of 3 in Values, step 1 of 27 in Language basics.

Next →

The script shape in other languages