Menu
Coddy logo textTech

Naming Conventions

Part of the Fundamentals section of Coddy's Lua journey — lesson 10 of 90.

Good naming conventions make your code easier to read, understand, and maintain.

In Lua, variable names must follow certain rules. They can contain letters, numbers, and underscores, but they must start with a letter or underscore. Names like playerScore, health_points, and _tempValue are all valid, while 2players or my-score are not.

When naming variables, choose descriptive names that clearly indicate what the variable stores. Instead of using vague names like x or data, use specific names like playerLevel or gameScore. This makes your code self-documenting and much easier to understand later.

For multi-word variable names, Lua programmers commonly use either camelCase (like playerHealth) or underscores (like player_health). Both styles are acceptable - the key is to be consistent throughout your code. Choose one style and stick with it in your projects.

Try it yourself

This lesson doesn't include a code challenge.

quiz iconTest yourself

This lesson includes a short quiz. Start the lesson to answer it and track your progress.

All lessons in Fundamentals