lua-users home
lua-l archive

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


Hi, i don't understand Upvalues very well and i'm trying to create a function that returns a string and has 2 upvalues, could someone give me a example of function that when debugged shows nups (number of upvalues) equal 2?



static int teststring (lua_State *L) {
int n = lua_gettop(L);
std::str = "test"
static int val;
const char *cstr = str.c_str();
lua_pushstring(L, cstr);
return 1; 
}

Now when i debug that function i want it to have 2 upvalues so i should use 

 lua_pushcclosure(L, &anotherfunc, 1);   ? I didn't quite understood this