CodeToLive

Introduction to Lua

Lua is a powerful, efficient, lightweight, embeddable scripting language. It supports procedural programming, object-oriented programming, functional programming, data-driven programming, and data description.

Why Learn Lua?

Lua is widely used in game development (like World of Warcraft, Angry Birds), embedded systems, and as a general-purpose scripting language. It's known for its simplicity, small footprint, and excellent performance.

Your First Lua Program

Let's start with the traditional "Hello, World!" program in Lua:

print("Hello, World!")

Basic Syntax

Lua has a simple and clean syntax. Here are some key points:

  • Statements don't require semicolons (though they can be used)
  • Comments start with -- for single line or --[[ ... ]] for multi-line
  • Variables are global by default (use local for local variables)

Running Lua Code

You can run Lua code in several ways:

  1. Interactive mode (REPL): Just type lua in your terminal
  2. From a file: lua filename.lua
  3. Embedded in applications (like game engines)

Next Steps

Now that you've been introduced to Lua, you're ready to learn about variables and data types in Lua.