lua-users home
lua-l archive

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


Maybe the some internal function change the 0's type. I got your advise. Thanks.

Here are the code:

GetValue's C code:
static int GetValue_Factory(lua_State *L)
{
  lua_pushcclosure(L, GetValue, 2);
  return 1;
}

static int GetValue(lua_State *L)
{
  lua_pushvalue(L, lua_upvalueindex(1));
  lua_gettable(L, lua_upvalueindex(2));
  return 1;
}


At 2012-07-16 17:39:46,"steve donovan" <steve.j.donovan@gmail.com> wrote: >On Mon, Jul 16, 2012 at 11:34 AM, zaker <zgmfzaku@163.com> wrote: >> what i want to know is that when i write lua code like "GetValue( 0, table >> )" . what is the 0's type, number or string ? >> I got the result that 0's type is string. > >I think you should show us GetValue()'s code. > >One problem that does happen is that if you say lua_tostring(L,-1) it >actually _converts_ the value on the stack. So the right thing to do >is to check the type of the value before calling this. > >steve d. >