noeska
23-05-2004, 10:37 PM
Is anyone using lua together with delphi here? How can lua access delphi variables? Thanks for your answer in advance!
noeska
24-05-2004, 11:36 AM
meanwhile i discovered that setting (exporting) a global var to lua goes like:
//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:
//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?
Powered by vBulletin® Version 4.2.5 Copyright © 2024 vBulletin Solutions Inc. All rights reserved.