lua global variable code example

Example 1: lua variables

local NumberVariable = 1
local StringVariable = "TextHere"
local BooleanVariable = true --// can also do false

Example 2: lua make variable global

varname = varval

Example 3: lua variable

-- Private Variable
local name1 = "John"

-- Public Variable
name2 = "Jane"

print(name1)
print(name2)

Example 4: global variables lua

--[[
Global variables don't need a declaration like "local." Instead, you'd just
write like this:
]]--

variable = --value

--[[ 
Note, you don't always have to even assign a value to a variable. You can
use it for the first time and get a value of "nil" which you can update later.
]]--

Tags:

Lua Example