I am testing about calling LUA scripts from C. LUA 5.3.5.
To tighten the libraries used, in C I am using
L = luaL_newstate();
luaopen_base(L);
luaopen_string(L);
luaL_dofile(L, szFilename);
int tipo = lua_getglobal(L, "check");
int error = lua_pcall(L, 0, 0, 0);
(code simplified and without error handling)
This is the sample LUA script:
function check()
local buffer = "hello"
buffer = buffer .. " world!"
print(buffer)
print(string.len(buffer))
end
Why does string.len return error?
attempt to index a nil value (global 'string')
I thought luaopen_string loads the string library.