Your First Lua Script
Let’s write our first Lua program to get comfortable with the syntax.
Hello, World!
print("Hello, World!")
print()
is the built-in function used to display output in the console.
How to Run:
- Create a file named
hello.lua
- Add the code above to it
- Open your terminal and run:
lua hello.lua
That’s it! You’ve just written your first Lua script.
Try This:
name = "Klaus"
print("Hello, " .. name)
This introduces string concatenation using the ..
operator in Lua.