Variables

A Lua variable is a name with an associated value.

Variables are declared and assigned values using the = operator.

local name = "Tracy"

The variable scope is determined by whether the variable is declared as local or global.

  • All variables are considered global unless explicitly declared as a local. Global variables are accessible throughout the entire Translator script.

  • A local variable is limited to the block or function wherein it was declared.

In the screenshot below you can see an example of variable scope: Within the variableFunction https://interfaceware.atlassian.net/wiki/spaces/IXB/pages/2684846443, we can view the values of both the local and global variables. The scope of the local variable is restricted to the variable function and is not traceable in main.

This leads into the concept of https://interfaceware.atlassian.net/wiki/spaces/IXB/pages/2691006685 as we see the local variable returned nil instead of the string “I am local“.

Â