lua-users home
lua-l archive

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


Ok i answer now my question self
 
All what u must do is, push the count of arguments and return
ur function with the count of pushed values to lua stack

static int Puts (lua_State *lua)
{
 int n = lua_gettop(lua); /* number of arguments */
 lua_Number sum = 0;
 int i;
 for (i = 1; i <= n; i++)
 {
   printf("%s",lua_tostring(lua, i));
 }
 lua_pushstring (lua, "NEIN");
 return 1;   <<<<<---------- RETURN COUNTS of pushed members MEN
}

Thanks for read me

 

 

----- Original Message -----
Sent: Thursday, March 02, 2006 7:59 PM
Subject: this

Hi !
I must call my LuaObjects with an "this" statement
but i can call declared functions via lua_pushcclosure()
unless this, now i will that my static
function returns
an value
or string, that works not so how in LuaObjectCallback
what i must
do , so my MyPrint returns a value to Luascript?
very thanks
for read me !
Karsten Schulz Berlin

In my C++ i declare an static function
---------------------------------------------
static int MyPrint(lua_State *lua)
{
printf("%s",lua_tostring(lua, 1));
//->dont work so-> lua_pushstring (lua, "AnswerText");
return 0;
}

//and declare the function
lua_pushcclosure (m_pState, MyPrint, 0);
lua_setglobal (m_pState, "MyPrint");
---------------------------------------------


In
my Lua, i call the function
----------------------------------------------
v = trace ("start\r\n")
print("MyPrint return:",v);
---------------------------------------------
No return value i can get