I am trying to load a table into C++ from Lua. This is how the file looks:
function alma(arg)
print(arg)
end
sometable = {
num = 5,
text = "this is a string",
nested = {
{"a", alma("argument")},
{"table", alma("arg")},
{"element", alma("asd")}
}
}
If I call luaL_loadfile I only get the chunk. If I call lua_dofile I get the elements, but the alma function runs for each element. In this SO thread, someone said to wrap these kinds of stuff into functions and call that to get the data. When i wrap/call the function the 3 alma functions run the moment i call the getter. How can i get sometable and its elements without executing the alma function?
almawill be invoked only when you access corresponding element for the first time. This feature is transparent: you will not have to invoke some function explicitly.