July 2018
Beginner
202 pages
5h 42m
English
Up until now, we have only been working with basic Lua types and functions. Lua's C API also allows us to work with tables. A new table can be created with the lua_newtable (lua_State*) function. This function returns nothing and only takes the Lua state as an argument. The lua_newtable function will create an empty table and leave it on top of the stack. Once the table is on the stack, it's up to you to assign it to a variable. For example, the following code creates a table named "vector" that has global scope:
lua_newtable(L);lua_setglobal(L, "vector");
The C API for working with tables can get a little verbose. There are a few libraries that address this and aim to reduce the amount of code you have to actually ...