Run Luau Modules
Lesson 1 of 48 in Coddy's Luau for GDScript Developers course.
You already know GDScript functions, collections and classes. Luau is a language derived from Lua with gradual static types and additional syntax. This course teaches general programming, not Roblox APIs. Run the supplied two-file program now.
The editable app.luau returns a module table. The locked main.luau loads it using require("./app"), reads input and prints its result. Coddy supplies io.lines and io.read through a patched CLI; upstream Luau does not provide this stdin library. Do not assume filesystem access.
The runner uses the pinned Luau 0.731 build. It runs luau-compile --null for syntax and then executes the program. It does not run luau-analyze. Annotations describe intended types; runtime guards and behavior tests enforce these tasks. Supplementary local analyzer checks are separate evidence.
Source snippets extend SceneTree only to run as small command-line Godot programs and call quit afterward. The Luau tasks are plain modules: no Node, signals, scene resources or Roblox APIs are assumed.
Challenge
BeginnerRun the supplied program. No edits or input are required. It returns Luau is ready.
Edit app.luau. The visible locked main.luau reads stdin into a sequence of lines, calls app.run(lines), and prints its returned value with one final newline. Do not print diagnostics or change the module names. Empty input gives an empty sequence. All numeric inputs are small enough to avoid overflow.
Try it yourself
local app = require("./app")
local lines = {}
for line in io.lines() do lines[#lines + 1] = line end
print(app.run(lines))
All lessons in Luau for GDScript Developers
1First Luau Programs
Run Luau ModulesPrint and CommentNames and Local ScopeNumbers and ConversionStrings and Byte IndexesRecap: Format a Receipt4Functions and Closures
Functions and ReturnsDefaults and Options TablesMultiple Results and VarargsCallbacks and Captured StateRecap: Pricing Functions2Values and Decisions
Null and Missing FieldsTruth and Default ValuesBranches and BoundsEquality and IdentityRecap: Admission RulesPractice on your own: Online Luau compiler