lua-users home
lua-l archive

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


How would I be able to get the return value of a Lua function
called in my application?

My C code is this:
    printf("Result In C: %d \n", lua_getresult(1));

and my function is:
  function luafunc(value)
	write("In Lua Function \n");
	write("Value Is: ");
	return (value * value) ;

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,