[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Getting return value of a lua function called in C
- From: "Shawn LeBlanc" <wrlddomprod@...>
- Date: Tue, 29 Feb 2000 09:24:23 -0800
Greetings!
How would I be able to get the return value of a Lua function
called in my application?
My C code is this:
lua_pushnumber(8);
lua_callfunction(lua_getglobal("luafunc"));
printf("Result In C: %d \n", lua_getresult(1));
and my function is:
function luafunc(value)
write("In Lua Function \n");
write("Value Is: ");
write(value);
write("\n");
return (value * value) ;
end
When I call lua_getresult(1), I get the same result no matter
what I feed the the function. I changed the rest of the lua script
just in case it was affecting my function, but I get the same
result, nonetheless. I'm always getting 3 when I call lua_getresult(1).
I should be getting 64. Is this the right way of doing it?
And do I use lua's format() if I want to format a string like C's
printf()? For example, if I wanted to write something similar to
"printf("%d",value);" in Lua, should it be "write(format("%d",value));"?
I've tried it, but it doesn't work. I may be missing something.
with milk and cookies,
Shawn