lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


I been trying to get this small application to run since it's a
testbed for future functionality on my game engine. But i am having
some trouble trying to get it to call a function inside a lua table
from C++. More precisely is passing more than one parameter to the lua
function, return values work fine. also calling a function that's not
member of a table works flawlessly without any of the argument
trouble.


This is my code without comments and debugging functions.
inside my main function in c++ i call 4 functions each one returning 1
if they execute correctly or 0 otherwise.

their name reflects the amount of parameter than they take and test for.
i have spended about 5 hours today with this trying different
approaches. so any ideas or suggestions would be greatly appreciated
my suspicions are that something i am doing with the stack
manipulation section is wrong. but doubt it because it works fine with
less than 2 arguments and because when i dump the stack the values
appear to be what they should be. ie

table
function
argument
argument

after doing the pcall the only thing left on the stack is:
table
number
the number being the return value and i assume the table is the one
the function was member of.

//main.cpp
http://pastebin.com/m2f1787b
//add.lua
http://pastebin.com/m59b0ead9

Anner