Read a crate direction
Before you start this beginner track
Variables, loops, and sequences. Lua sequence indexes start at one.
Guided code reading and debugging. Runnable coding challenges are available in JavaScript, Python, and SQL.
Understand it, then try it.
The string library extracts and transforms text. string.sub uses inclusive byte positions, and omitting its last position takes the rest of the string. The label has a six-character prefix, crate-. Extract its suffix, then convert it to uppercase to make a short, readable routing label.
local label = "crate-south"local direction = string.sub(label, 7)local sign = string.upper(direction)print(sign)Each mission is a standalone Lua 5.4 script with standard libraries. Tables used as sequences have consecutive integer keys starting at 1 and no gaps. All string examples use ASCII text.
Track the values line by line. Predict the result before running this example in your own editor.