I was using LUA like 15 years ago :) So, well, I have forgotten how it worked :) Also I have forgotten how exactly it was called what I want to make so I have trouble googling it.
I need a very simple thing only, a lua script that calls my C++ functions. I recall you were initailizing lua, then specified which lua script to parse (filename) and then define "binding" or was it "registering" a function?
I don't need other fancy stuff, only this.
EDIT: It seems the function I used in the past was lua_register which was deprecated and now you use some "table" thing? Below is a code that compiles but has no effect (luaPrint not working):
int luaPrint(lua_State *L)
{
tPrint("%s\n", lua_tostring(L, -1));
}
int testLua()
{
lua_State *L = luaL_newstate();
luaL_Reg Regs[] =
{
{ "print", luaPrint },
{ NULL, NULL }
};
lua_newtable(L);
luaL_setfuncs(L,Regs,0);
lua_pushvalue(L,-1);
if(luaL_dofile(L, "test.lua"))
{
tPrint("Error:%s\n", lua_tostring(L, -1));
}
lua_close(L);
return 0;
}