July 2018
Beginner
202 pages
5h 42m
English
A LuaRef variable can point to any type of data—even a table! When a LuaRef variable points to a table, it can be indexed very naturally using brackets ([]). Consider the following Lua code:
velocity = { x = 7, y = 0, units = "miles"}velocity.debug = function() print (velocity.x .. ", " .. velocity.y .. " " .. units .. " / hour")end
We can access, and even change, any variable located in the velocity table by using a LuaRef object. The following code sample demonstrates this:
LuaRef v = getGlobal(L, "velocity");v["y"] = 6v["units"] = "km"v["debug"]();