JMW
Aspiring Addon Developer
Someone please put me out of my misery.
How do I call a Lua function from C++ ? and...
Specifically, I want to pass my variable "altm" into the stock Lua Script "aap.lua" value "alt", from my routine in .dll
I've read multiple articles, cut n pasted for hours, but to no avail.
Does this resemble anything that would do it?
Showing my ignorance of Lua (and other things) does the function alt_ap have to be called as well or does it run when aap.lua is loaded? If so, how?
:sos:
How do I call a Lua function from C++ ? and...
Specifically, I want to pass my variable "altm" into the stock Lua Script "aap.lua" value "alt", from my routine in .dll
I've read multiple articles, cut n pasted for hours, but to no avail.
Does this resemble anything that would do it?
Code:
int ShuttlePB::clbkGeneric (int msgid, int prm, void *context)
{
switch (msgid) {
case VMSG_LUAINTERPRETER:
lua_State *L = (lua_State*)context;
luaL_dofile (L, "Script\\35B\\aap.lua");
lua_pcall(L, 0, LUA_MULTRET, 0);
lua_getglobal(L, "alt_ap (alt)");
lua_pushnumber(L, 500); // altm <---THE VALUE I WANT TO PASS
lua_pcall(L, 1, 1, 0);
lua_pop(L,1);
return VMSG_LUAINTERPRETER;
}
return 0;
}
Showing my ignorance of Lua (and other things) does the function alt_ap have to be called as well or does it run when aap.lua is loaded? If so, how?
:sos: