[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: How to call functions inside a table from C?
- From: "Edmar" <edmar.souza@...>
- Date: Thu, 25 Jan 2007 16:24:18 -0300
**Sorry for my bad English. **
Good day.
I'm trying to call a function declared inside a lua table, from my code in
"C". This is my lua code:
MinhaTabela=
{
textos =
{
textoSair = "Aperter ESC para sair a qualquer momento",
textoEnter = "Aperte enter para jogar"
},
variosCirculos2 =
function ()
for X=1, 30 do Circulo(X * 10,X * 10,X * 5,X * 10,X * 5,0); end
Atualizar();
end,
relogio =
function ()
ty = ty + 2;
tx = tx + 5;
end
}
So, how can I call the functions 'variosCirculos2" or "relogio" from C? This
is the code that I use to call Lua functions:
void ScriptInterface::CallFunction(char *funcName)
{
lua_getglobal(L, funcName);
if(lua_pcall(L, 0, 0, 0) != 0)
{
cout << "Erro ao chamar função: "
<< lua_tostring(L, -1)
<< endl;
}
}
Thanx for the atention.