meanwhile i discovered that setting (exporting) a global var to lua goes like:
Code:
//set global var A with value 10
//this pushes the globals table of state L
lua_pushvalue(L, LUA_GLOBALSINDEX);
//this sets a key in the globals table of L
lua_pushstring(L, 'a'); //Be aware lua vars are case sensitive!! a<>A
lua_pushnumber(L, 100);
lua_settable(L, LUA_GLOBALSINDEX); // global noot = "mies"
//end set
And reading a global var from lua to delphi goes like:
Code:
//read global var from lua
//this pushes the globals table of state L
lua_pushvalue(L, LUA_GLOBALSINDEX);
lua_pushstring(L, 'result');
lua_gettable(L, LUA_GLOBALSINDEX); // global aap
writeln('Delphi: '+floattostr(lua_tonumber(L, -1))); //why -1?
//end read
This should get me going.
But on looking on the lua maillist archive i read it should be possible to use c++ classes from within lua? Does this also go for delphi objects? How?
Bookmarks