l2c_getUserItems() done

This commit is contained in:
alexey.min
2012-05-12 19:39:01 +00:00
parent 3f7769292c
commit 0506593508
5 changed files with 71 additions and 4 deletions

View File

@@ -71,3 +71,48 @@ int l2c_getPaperdollItem( lua_State *L )
lua_pushnumber( L, pusr->paperdoll_oid[ slot ] );
return 2;
}
// table l2c_getUserItems()
int l2c_getUserItems( lua_State *L )
{
if( !g_game_client ) { lua_pushboolean( L, 0 ); return 1; }
UserInventory *inv = &(g_game_client->ai.inv);
//
int tableIndex = 1;
lua_createtable( L, 0, 0 );
int i = 0;
char itemName[255] = {0};
for( i=0; i<UserInventory::USERINV_MAX_ITEMS; i++ )
{
if( inv->item[i].isUnused() ) continue;
inv->item[i].getItemName( itemName, sizeof(itemName)-1 );
lua_pushnumber( L, tableIndex );
lua_createtable( L, 0, 0 );
//
lua_pushstring( L, "itemId" );
lua_pushinteger( L, inv->item[i].itemID );
lua_settable( L, -3 );
//
lua_pushstring( L, "itemName" );
lua_pushstring( L, itemName );
lua_settable( L, -3 );
//
lua_pushstring( L, "objectId" );
lua_pushinteger( L, inv->item[i].objectID );
lua_settable( L, -3 );
//
lua_pushstring( L, "isEquipped" );
lua_pushboolean( L, inv->item[i].isEquipped );
lua_settable( L, -3 );
//
lua_pushstring( L, "count" );
lua_pushnumber( L, (lua_Number)inv->item[i].count );
lua_settable( L, -3 );
//
lua_settable( L, -3 );
tableIndex++;
}
//
return 1;
}