lua variable code example

Example 1: lua local

local name = "jojo"
print("Hello, "..name)

Example 2: lua make variable global

varname = varval

Example 3: lua value

-- Nil (no value)
-- Number => Example: 1234567890
-- String => Example: "random text"
-- Function
-- Userdata
-- Boolean (true/fanse)
-- Table
-- Thread

Example 4: lua variables

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

Example 5: lua variable

-- Private Variable
local name1 = "John"

-- Public Variable
name2 = "Jane"

print(name1)
print(name2)

Example 6: Lua variable

-- Variables are global by default:
globalVariable = 10
-- To make a variable local:
local localVariable = 20

Tags:

Lua Example