I have strange problem, with calling Lua function from C++. I have in Lua:
Player =
{
Number = 0.43,
Text = "SomeText",
}
function Player:Func(a, b)
return (a * b);
end
Before lua_pcall my stack looks:
table
function
3
4
I call this function with:
lua_pcall(L, 2, 1, 0)
And I get error from Lua:
attempt to perform arithmetic on local 'b' (a nil value)
When I change in Lua script
return (a * b);
to
return a;
There is no error, but from lua_tonumber(L, -1); I get value 4 (my second argument in C:/), so it looks that my second argument in C is first in Lua.
Do you know what I made wrong in my code ?
How I construct stack:
lua_getglobal (L, "Player");
lua_pushstring(L, "Func");
lua_gettable(L, -2);
lua_pushnumber(L, 3.0);
lua_pushnumber(L, 4.0);
this
pointer (or Lua equivalent)? - Ben Voigt