
Every programming journey starts with a single line, and in Lua, that line is beautifully simple. You will learn how to use the Lua print function to display text and numbers to the console. This lecture covers how Lua handles string literals inside double and single quotes, how to print multiple values separated by commas, and how the print function automatically adds a newline after each call. By the end, you will be writing Lua code that outputs greetings, numbers, and combinations of both to the screen — your very first conversation with the Lua interpreter.
Variables are the sticky notes of programming — little labeled containers where you stash information for later. In Lua, creating a variable is as easy as picking a name and using the assignment operator. This lecture walks you through how Lua variables work, including the rules for naming them, how assignment with the equals sign stores values, and how you can reassign a variable to a completely different value or even a different type at any time. You will also discover that Lua variables are global by default, which is a quirk that sets Lua apart from many other languages. Expect to write short Lua snippets that create, update, and print variables.
Lua treats numbers with a refreshing simplicity — there is one number type, and it handles both integers and decimals without you needing to declare which is which. In this lecture, you will explore Lua arithmetic operators including addition, subtraction, multiplication, division, floor division, modulo, and exponentiation. You will see how Lua performs floating-point division by default and how the floor division operator gives you whole-number results. Short Lua code examples will show you how to chain operations, use parentheses to control order of operations, and store calculated results in variables.
Strings are how Lua handles text, and they are everywhere — from user-facing messages to data labels. This lecture teaches you how to create strings in Lua using double quotes, single quotes, and the special double-bracket syntax for multi-line strings. You will learn how the Lua concatenation operator (two dots) joins strings together and how to combine strings with numbers using this operator. The lecture also covers the tostring and tonumber functions for converting between types, and the hash operator for getting a string's length. You will write Lua code that builds dynamic messages by concatenating variables and literal text.
In Lua, truth is straightforward but has one surprising twist — only false and nil are considered falsy, while everything else, including zero and empty strings, is truthy. This lecture introduces the Lua boolean type with its two values, true and false, and the special Lua type nil, which represents the absence of a value. You will learn how Lua uses nil to signal that a variable has not been assigned or has been explicitly cleared. Short Lua snippets will demonstrate how to assign boolean values, test for nil, and observe how Lua's truthiness rules differ from languages like Python or JavaScript. Understanding these two types is essential for writing correct Lua conditionals later on.
Lua is dynamically typed, which means a variable can hold a string one moment and a number the next. The built-in type function is your detective tool for figuring out what kind of value a variable currently holds. In this lecture, you will learn how to use the Lua type function, which returns a string like "number," "string," "boolean," "nil," "table," or "function." You will write Lua code that checks the type of various values, stores those type strings in variables, and uses print to display them. This skill is particularly useful for debugging and for understanding how Lua automatically handles type coercion in certain situations.
The if statement is where your Lua code learns to think. Instead of blindly executing every line, Lua can evaluate a condition and choose what to do based on whether that condition is true or false. This lecture covers the syntax of Lua if-then-end blocks, how to use comparison operators like equals, not equals, less than, greater than, and their or-equal variants, and how Lua evaluates the condition to decide which code runs. You will write Lua snippets that compare numbers and strings, printing different messages depending on the result. This is the foundation of every decision your Lua programs will ever make.
Sometimes life gives you more than two choices, and your Lua code needs to handle that gracefully. This lecture extends the basic if statement by introducing the elseif and else keywords in Lua, letting you chain multiple conditions together so your program can pick from several possible paths. You will learn how Lua evaluates elseif branches from top to bottom and stops at the first true condition, and how the else block acts as a catch-all when nothing matches. The lecture also covers nesting one if block inside another for more specific logic. Lua code examples will demonstrate grading systems, range checks, and multi-condition branching.
When a single condition is not enough, Lua's logical operators let you combine and invert conditions to express exactly what you mean. This lecture teaches you how to use the Lua keywords and, or, and not to build compound conditions. You will discover that Lua's and operator returns the first falsy value or the last value if all are truthy, and that or returns the first truthy value — a behavior that enables a handy idiom for default values. The not operator simply flips true to false and vice versa. You will write Lua code that combines multiple comparisons into single, readable conditions and uses the or-default pattern to assign fallback values.
Loops are the workhorses of programming, and the while loop is the most intuitive one — keep doing something as long as a condition is true. In Lua, the while loop checks its condition before each iteration and runs the block only if the condition holds. This lecture covers the syntax of Lua while-do-end blocks, how to set up a counter variable, update it inside the loop, and avoid infinite loops by making sure the condition eventually becomes false. You will write Lua code that counts up, counts down, sums a series of numbers, and prints patterns using while loops. It is simple, powerful, and the gateway to understanding all Lua loops.
When you know exactly how many times you want to repeat something, the numeric for loop in Lua is your best friend. It is cleaner than a while loop because the initialization, limit, and step are all declared in one line. This lecture teaches you the syntax of Lua's numeric for loop, including how to specify a start value, an end value, and an optional step value. You will learn that the loop variable is local to the loop body automatically and that Lua evaluates the limit and step only once before the loop begins. Lua code examples will demonstrate counting forwards, counting backwards with a negative step, and iterating through even or odd numbers.
Lua offers a loop that most languages skip — the repeat-until loop, which is like a while loop that always runs at least once before checking its condition. This lecture introduces the Lua repeat-until syntax, where the code block executes first and then the condition is evaluated at the bottom. If the condition is false, the loop repeats; if true, it stops. You will learn when repeat-until is more natural than while, such as input validation patterns or retry logic. Lua code examples will show you how to build loops that guarantee at least one execution, comparing them side by side with equivalent while loops so you can see exactly when each style shines.
Sometimes you need to bail out of a loop early — maybe you found what you were looking for or hit an error condition. In Lua, the break statement immediately exits the innermost loop, skipping any remaining iterations. This lecture covers how to use break inside Lua while, for, and repeat-until loops, and how to combine break with if statements to create conditional exits. You will also learn that Lua does not have a continue keyword like some other languages, and you will see a common Lua pattern using a conditional wrapper or goto to skip to the next iteration. Short Lua code examples will demonstrate searching through a list of numbers and stopping as soon as a target is found.
Functions in Lua are your way of packaging a block of code, giving it a name, and calling it whenever you need it — like saving a recipe you can cook on demand. This lecture covers the syntax for defining a Lua function using the function keyword, naming it, adding parameters in parentheses, and closing it with end. You will learn how to call a Lua function by name with arguments, how Lua silently discards extra arguments and fills missing ones with nil, and how to use the return keyword to send a value back to the caller. Lua code examples will walk you through creating simple functions that take inputs, perform calculations, and return results.
Most programming languages let a function return one thing. Lua says why stop there? In Lua, a function can return multiple values separated by commas, and the caller can capture all of them in a single assignment. This lecture teaches you how to write Lua functions that return two or more values, how to receive those values into multiple variables, and what happens when you ignore some of the returned values. You will also learn how Lua adjusts the number of returned values depending on where the function call appears — a subtle but important detail. Lua code examples will show functions that return both a result and a status, divide with quotient and remainder, and swap two values.
In Lua, every variable you create without the local keyword is global, which can lead to accidental name collisions and hard-to-find bugs. This lecture explains how the Lua local keyword creates variables that are only visible within the block where they are defined — whether that block is a function body, a loop, or an if statement. You will learn the difference between local and global scope in Lua, how inner blocks can see variables from outer blocks but not the reverse, and why experienced Lua programmers default to local for almost everything. Lua code examples will demonstrate shadowing, accidental globals, and the performance benefit of using local variables.
In Lua, functions are first-class values, meaning you can store them in variables, pass them as arguments, and return them from other functions — just like numbers or strings. This lecture introduces anonymous functions in Lua, which are functions defined without a name using the function keyword directly in an expression. You will see that even named Lua functions are really just variables holding function values. Lua code examples will show you how to assign a function to a variable, pass a function as a callback to another function, and store functions in a table. This concept is a gateway to powerful patterns in Lua programming.
A closure is what happens when a Lua function remembers the variables from the scope where it was created, even after that scope has ended — like a photograph that captures a moment in time. This lecture explains how closures work in Lua by showing you how an inner function can access local variables from its enclosing function, and how those captured variables, called upvalues, persist as long as the closure exists. You will write Lua code that creates counter functions, factory functions that generate customized behavior, and accumulators that maintain state between calls. Closures are one of Lua's most elegant features, and understanding them unlocks a whole new level of expressive power.
Sometimes you do not know in advance how many arguments a function will receive, and Lua handles this beautifully with the vararg expression, written as three dots. This lecture teaches you how to define variadic functions in Lua using the ellipsis syntax, how to access the variable arguments using the select function and the curly-brace table constructor, and how to count the number of arguments passed. You will learn the Lua idiom of collecting varargs into a table for easier processing and how select with a hash returns the total count including nil values. Lua code examples will demonstrate building a custom print wrapper, a sum function that takes any number of inputs, and a string formatting helper.
Tables are the only data structure in Lua, and they do everything — arrays, dictionaries, objects, you name it. This lecture introduces the Lua table constructor using curly braces and shows you how to create array-style tables with sequential integer keys starting at one. You will learn how to access elements using square-bracket indexing, how Lua arrays are one-indexed unlike most languages, and how to add new elements by assigning to the next index. The lecture also covers the hash operator to get the length of an array-style table. Lua code examples will walk you through creating lists of names, accessing them by position, and appending new items.
Beyond simple lists, Lua tables can act as dictionaries where each value is associated with a named key rather than a numeric index. This lecture teaches you how to create key-value tables in Lua using both the bracket syntax and the constructor shorthand where keys look like field names. You will learn how to read and write values using square-bracket notation with string keys and the more convenient dot notation shorthand. The lecture covers when you must use brackets versus when dot notation works, and how to remove a key by setting its value to nil. Lua code examples will show you building a player profile with named attributes and updating individual fields.
Once you have data in a Lua table, you need a way to walk through it. Lua provides two built-in iterator functions for this purpose: ipairs for array-style sequential keys and pairs for all keys including string keys. This lecture explains how to use the Lua generic for loop with ipairs to iterate through integer-indexed entries in order, and with pairs to iterate through every key-value pair in an unspecified order. You will learn the difference between the two, why ipairs stops at the first gap in the sequence, and when to choose one over the other. Lua code examples will loop through lists of items and dictionaries, printing each key and value.
Real-world data is rarely flat — it has layers, like a table inside a table inside a table. In Lua, you can nest tables to any depth, creating rich data structures that represent complex relationships. This lecture shows you how to create nested tables in Lua, how to access deeply nested values by chaining square brackets or dot notation, and how to iterate over tables that contain other tables. You will also learn how to check whether a nested key exists before accessing it to avoid errors. Lua code examples will build a small data structure representing a collection of characters, each with their own attributes stored in sub-tables.
Lua comes with a handy table library that provides utility functions for working with array-style tables. This lecture walks you through the most essential functions in the Lua table library: table.insert for adding elements at any position, table.remove for pulling elements out, table.sort for ordering elements in place, and table.concat for joining array elements into a single string. You will learn how each function modifies the table directly and how to provide a custom comparison function to table.sort for non-standard ordering. Lua code examples will demonstrate building a list, inserting and removing items, sorting alphabetically and numerically, and concatenating results into formatted output.
One of the most important things to understand about Lua tables is that they are always passed by reference, not by value. When you assign a table to a new variable or pass it to a function, both names point to the exact same table in memory — changing one changes the other. This lecture demonstrates this Lua behavior with clear code examples that show two variables referencing the same table, how modifications through one variable are visible through the other, and how to create a shallow copy when you genuinely need an independent duplicate. Understanding reference semantics in Lua prevents a whole category of subtle bugs and is essential knowledge for writing correct programs.
Lua's string library is packed with functions that let you slice, transform, and inspect text with ease. This lecture covers the most commonly used functions in the Lua string library: string.upper and string.lower for case conversion, string.sub for extracting substrings by position, string.len as an alternative to the hash operator, string.rep for repeating a string, and string.reverse for flipping it. You will also see how Lua lets you call these as methods using the colon syntax on string values. Lua code examples will manipulate text data, extract portions of strings, and build formatted output using these functions together.
Lua does not use regular expressions — instead, it has its own lightweight pattern matching system that is simpler but still powerful for most tasks. This lecture introduces Lua pattern matching through the string.find and string.match functions. You will learn how string.find locates a pattern inside a string and returns its start and end positions, while string.match returns the captured text itself. The lecture covers basic Lua pattern characters like the dot for any character, percent-letter classes like %d for digits and %a for letters, and quantifiers like plus and star. Lua code examples will search for numbers in text, extract words, and validate simple formats.
When you need to find every occurrence of a pattern or replace them all, Lua gives you string.gmatch and string.gsub. This lecture teaches you how string.gmatch in Lua returns an iterator that yields each match in sequence, making it perfect for use in a for loop to process all matches one by one. You will also learn how string.gsub replaces every occurrence of a pattern with a new string and returns both the result and the count of replacements made. The lecture covers capture groups using parentheses in Lua patterns and how they let you extract specific pieces of matched text. Lua code examples will split sentences into words, extract key-value pairs from formatted strings, and perform find-and-replace operations.
As your Lua programs grow, stuffing everything into one file becomes a headache. Lua's module system lets you organize code into separate files and load them with the require function. This lecture explains how to create a Lua module by writing a file that builds a table of functions and returns it, and how to load that module in another file using require. You will learn how require caches the module so it is only executed once, how the return value becomes the module's public interface, and the naming conventions that make modules discoverable. Lua code examples will create a small math utility module with a couple of functions and then require and use it from a separate script.
When something goes wrong in a Lua program — a file that does not exist, a nil value where a number was expected — the default behavior is to crash with an error message. The Lua functions pcall and xpcall let you catch those errors gracefully and decide what to do instead. This lecture teaches you how pcall wraps a function call in protected mode and returns a boolean success flag along with either the result or the error message. You will also learn how xpcall adds a custom error handler that can capture a stack traceback for debugging. Lua code examples will deliberately trigger errors, catch them with pcall, inspect the error messages, and use xpcall to generate detailed diagnostic output when things go sideways.
Embark on your Lua programming journey by writing your very first line of code that displays a message to the world. You'll master the print function, understand how Lua interprets your commands, and experience the thrill of seeing your code execute successfully while learning the essential syntax that forms the foundation of every Lua program.
Discover how to make your Lua code readable and maintainable by mastering single-line and multi-line comments. You'll learn professional commenting practices that help you document your thoughts, temporarily disable code sections, and create clear explanations that make your Lua programs understandable to both yourself and other developers.
Unlock the power of storing information in Lua by creating variables and exploring fundamental data types including numbers, strings, and booleans. You'll understand how Lua's dynamic typing system works, learn proper variable naming conventions, and practice storing different kinds of data that your programs can manipulate and use.
Master the art of text manipulation in Lua by learning string concatenation, escape sequences, and special characters. You'll discover how to combine strings creatively, insert quotes and new lines into your text, and format output beautifully using Lua's powerful string handling capabilities that bring your messages to life.
Transform Lua into your personal calculator by mastering arithmetic operations including addition, subtraction, multiplication, division, and modulo. You'll explore operator precedence, work with parentheses to control calculation order, and understand how Lua handles different numeric operations to perform complex mathematical computations effortlessly.
Master the fundamentals of creating and assigning values to variables in Lua, understanding how these named containers store your data without explicit type declarations. You'll practice declaring variables with meaningful names, reassigning values dynamically, and explore how Lua's flexible assignment system allows you to work with data effortlessly throughout your programs.
Dive deep into Lua's numeric system where integers and floating-point numbers coexist seamlessly, learning how to work with whole numbers and decimals for precise calculations. You'll explore number formatting, scientific notation, and understand how Lua automatically handles numeric conversions while maintaining accuracy in mathematical operations and data storage.
Unlock advanced string techniques in Lua including string length calculation, case conversion, and substring extraction using built-in string functions. You'll learn to transform text dynamically, search within strings, and apply powerful string methods that enable you to process user input and format output with professional precision.
Explore Lua's boolean values true and false along with the special nil value that represents absence of data, understanding how these fundamental types control program logic. You'll practice using boolean variables for flags and states, learn how nil works in variable initialization, and discover how Lua treats different values in boolean contexts.
Gain mastery over Lua's type system by learning to identify variable types using the type function and converting between different data types safely. You'll understand implicit and explicit type conversions, handle string-to-number transformations, and develop defensive programming habits that prevent type-related errors in your Lua applications.
Understand the critical distinction between local and global variables in Lua, learning how scope affects variable visibility and lifetime within your programs. You'll master the local keyword, explore best practices for variable scope management, and discover
Learn to give your Lua programs decision-making capabilities by mastering the if statement structure with its condition and code block execution. You'll write conditions that evaluate to true or false, understand proper indentation for readability, and create simple programs that respond differently based on variable values, laying the groundwork for intelligent Lua applications.
Master all six comparison operators in Lua including equals, not equals, greater than, less than, greater than or equal, and less than or equal to create powerful conditional expressions. You'll practice comparing numbers and strings, understand how Lua evaluates comparisons, and build complex conditions that allow your programs to make nuanced decisions based on data relationships.
Expand your decision-making toolkit by implementing if-else structures that provide alternative paths when conditions are false in your Lua programs. You'll create programs that always take action by defining both true and false outcomes, understand the flow of execution through branching paths, and develop the ability to handle binary decisions elegantly.
Build sophisticated multi-path decision trees using elseif statements that allow your Lua programs to evaluate multiple conditions in sequence. You'll learn to structure complex decision logic efficiently, understand the order of condition evaluation, and create programs that can choose between many different actions based on various criteria without nesting complexity.
Harness the power of and, or, and not operators to create sophisticated compound conditions that make your Lua programs incredibly flexible. You'll master combining multiple comparisons into single expressions, understand operator precedence and short-circuit evaluation, and build complex decision logic that can handle real-world scenarios with multiple requirements.
Take your Lua programming to the next level by nesting if statements inside other conditional blocks to create multi-layered decision structures. You'll learn to manage code complexity through proper indentation, understand when nesting is appropriate versus using logical operators, and develop the skills to model complex real-world logic in your Lua applications.
Master the fundamental while loop structure in Lua that executes code repeatedly as long as a condition remains true, giving you precise control over repetition. You'll create loops with proper conditions, understand the importance of updating loop variables to avoid infinite loops, and build practical examples that demonstrate how Lua automates repetitive tasks efficiently.
Discover the elegance of numeric for loops in Lua that automatically handle counter initialization, condition checking, and increment operations in a single compact statement. You'll learn to count up and down, use custom step values for creative iterations, and understand how Lua's for loop syntax simplifies common counting patterns while maintaining readable code.
Gain precise control over loop execution in Lua by mastering the break statement that allows early exit from any loop when specific conditions are met. You'll implement search algorithms that stop when finding target values, create interactive loops that respond to user input, and understand how strategic break placement makes your Lua programs more efficient and responsive.
Unlock the power of nested loops in Lua to work with two-dimensional patterns, grids, and complex data structures by placing loops inside other loops. You'll create multiplication tables, generate visual patterns, understand how inner and outer loop variables interact, and develop the spatial thinking needed to solve multi-dimensional problems in Lua programming.
Master essential loop patterns in Lua including accumulation, filtering, and finding maximum or minimum values through practical coding examples. You'll build running totals, count specific occurrences, process data systematically, and learn professional techniques that transform raw loops into powerful data processing tools used throughout Lua development.
Explore controlled infinite loops in Lua that run continuously until explicitly stopped, understanding their practical uses in game loops, menu systems, and interactive programs. You'll learn to combine infinite loops with break statements for user-controlled exits, implement event-driven patterns, and discover how Lua programmers use deliberate infinite loops to create responsive applicat
ions.
Learn to create your own custom functions in Lua using the function keyword, giving names to reusable blocks of code that perform specific tasks. You'll understand function syntax, practice defining simple functions that execute multiple statements, and discover how Lua functions help organize code into logical, manageable pieces that can be called whenever needed.
.
Master the art of making flexible functions by adding parameters that accept different values each time they're called in your Lua programs. You'll create functions with single and multiple parameters, understand how arguments are passed when calling functions, and build versatile code blocks that adapt their behavior based on the input data they receive.
Transform your Lua functions into powerful calculation engines by using the return statement to send values back to the code that called them. You'll practice returning single values, understand how returned data can be stored in variables or used in expressions, and create functions that process input and deliver meaningful results for further program use.
Explore advanced Lua function features including the ability to return multiple values simultaneously and accept variable numbers of arguments using the vararg syntax. You'll create functions that return several related results at once, work with the special ... notation, and understand how Lua's flexible function system surpasses many other programming languages in versatility.
Understand the distinction between local and global functions in Lua, mastering scope rules that determine where functions can be accessed within your programs. You'll learn to declare local functions for better code organization, explore function visibility across different code sections, and develop best practices that prevent naming conflicts while keeping your Lua code modular and maintainable.
Discover the powerful concept of functions as first-class values in Lua, where functions can be stored in variables, passed as arguments, and returned from other functions. You'll explore anonymous functions, create higher-order functions that operate on other functions, and understand how Lua's treatment of functions as data enables advanced programming patterns and flexible code design.
Master the elegant technique of recursion where Lua functions call themselves to solve problems by breaking them into smaller sub-problems. You'll implement classic recursive algorithms like factorial calculation and Fibonacci sequences, understand base cases that prevent infinite recursion, and learn when recursive solutions in Lua create cleaner, more intuitive code than traditional loops
This course contains the use of artificial intelligence (AI).
Lua is one of the most elegant and lightweight programming languages in the world, powering everything from video game engines like Roblox and World of Warcraft addons to embedded systems and web servers. Despite its small footprint, Lua punches well above its weight — and learning it opens doors to game modding, scripting, and rapid prototyping that heavier languages simply cannot match. Whether you have been curious about Lua for a while or just discovered it, this course gives you a clear, structured path from zero to confident coder.
This course takes you through five carefully designed sections that build your Lua skills from the ground up. You will start with the absolute basics — printing output, working with variables, numbers, strings, and booleans — before moving into control flow with if statements, while loops, for loops, and Lua's unique repeat-until construct. From there, you will dive into functions, learning how Lua treats them as first-class values, how closures and upvalues work, and how to write flexible variadic functions. The fourth section is dedicated entirely to tables, Lua's incredibly versatile data structure that serves as arrays, dictionaries, and objects all at once. You will finish with practical skills in string manipulation, Lua's pattern matching system, code organization with modules, file input and output, and robust error handling with pcall and xpcall.
This course is designed for complete beginners to Lua who have little or no prior programming experience, though anyone with experience in another language will find it a fast and efficient way to pick up Lua's unique features and idioms. By the end, you will be able to write clean, well-structured Lua scripts, work confidently with tables and functions, manipulate strings using patterns, organize your code into modules, and handle errors gracefully. Every concept is demonstrated through focused code examples that you can run and modify immediately.
What sets this course apart is its focus on one concept at a time, taught through concise code snippets rather than overwhelming projects. There is no filler, no fluff, and no hour-long lectures — just clear explanations paired with practical Lua code that you can type along with and understand. If you are ready to add Lua to your programming toolkit or start your coding journey with one of the friendliest languages out there, hit enroll and start writing Lua today.