• Studio

  • Bots

  • Web API

  • Designer Resources

  • Host Resources

  • CREATE

    Scripting

    Lua

    Best Practices

    Edit

    Naming Conventions

    When writing Lua scripts in Highrise Studio, it is essential to follow consistent naming conventions for variables, functions, and other identifiers. Naming conventions help improve code readability, maintainability, and collaboration among developers. By adhering to standard naming practices, you can create more organized and understandable Lua scripts that are easier to debug and maintain.

    General Guidelines

    • Use Descriptive Names: Choose names that clearly describe the purpose or functionality of the variable or function. Avoid using generic names like temp, data, or value that do not provide meaningful context.

    • Follow Consistent Casing: Use camelCase or snake_case for naming variables, functions, and other identifiers. Consistent casing makes it easier to distinguish between words and improves code readability.

    • Avoid Abbreviations: Minimize the use of abbreviations in variable and function names. While abbreviations can save typing time, they may reduce code clarity and make it harder for others to understand your scripts.

    • Be Concise and Clear: Keep names concise but descriptive. Aim for a balance between brevity and clarity to ensure that names are meaningful and easy to understand.

    • Use English Words: Write variable and function names in English to maintain consistency across your Lua scripts. English is the standard language for programming, and using English names helps make your code more accessible to a global audience.

    Examples

    Here are examples of naming conventions for variables and functions in Lua:

    Variables

    local playerName = "Alice"
    local playerScore = 100
    local isGameOver = false
    local playerInventory = { "Sword", "Shield", "Potion" }
    

    Functions

    function calculateDamage(attacker, target)
        -- Calculate damage based on attacker and target
    end
    
    function displayMessage(message)
        -- Display a message to the player
    end
    

    Constants

    
    local MAX_HEALTH = 100
    local GRAVITY = 9.81
    local PI = 3.14159
    

    By following these naming conventions, you can create Lua scripts that are more readable, maintainable, and consistent. Consistent naming practices contribute to better code quality and enhance the overall development experience in Highrise Studio.

    Summary

    • Descriptive Names: Use names that convey the purpose of variables and functions clearly.
    • Consistent Casing: Choose camelCase or snake_case and maintain a consistent style throughout your scripts.
    • Avoid Abbreviations: Minimize the use of abbreviations to improve code clarity and understanding.
    • Concise and Clear: Keep names concise but descriptive to strike a balance between brevity and clarity.
    • Use English Words: Write names in English to ensure consistency and accessibility in your Lua scripts.

    By adhering to these naming conventions, you can write clean, well-organized Lua scripts that are easier to read, understand, and maintain in Highrise Studio.

    Updated 2 months ago

    PocketWorlds Icon

    © 2024 Pocket Worlds. All rights reserved.