Lua variables
Translation results:
Lua is a lightweight and compact scripting language, written in standard C language and open in source code form. It is designed to be embedded in applications to provide flexible expansion and customization functions for applications.
Lua variablessyntax
Before using a variable, it must be declared in the code, that is, the variable must be created.
Before the compiler executes the code, the compiler needs to know how to open a storage area for the statement variable to store the value of the variable.
There are three types of Lua variables: global variables, local variables, and fields in tables.
Lua variablesexample
-- test.lua file script a = 5 a = local b = 5 – local variable function joke() c = 5 -- global variable local d = 6 -- local variables end joke() print(c,d) --> 5 nil do local a = 6 -- local variable b = 6 — Reassign local variables print(a,b); --> 6 6 end print(a,b) --> 5 6