Jump to content

[C++]Función item.get_attr() de PACI.


Shang

Mensajes recomendados

No doy soporte de como instalarla.

	int item_get_attribute(lua_State* L)
	{
		LPITEM item = CQuestManager::instance().GetCurrentItem();

		// If there's no item, it'll return 0
		if (!item)
		{

			lua_pushnumber(L, 0);
			return 1;
		}

		// If the function argument isn't a number, returns a syserr error
		if (!lua_isnumber(L, 1))
		{
			sys_err("item_get_attr_type error!! index must be a number");

			return 1;
		}

		// Saves the attribute type and value in integer variables
		int attrType = item->GetAttributeType(lua_tonumber(L,1)); 
		int attrValue = item->GetAttributeValue(lua_tonumber(L,1));
  
		// Creates a lua table
		lua_newtable( L );

		// Gets and inserts the item attribute type into the lua table
		lua_pushnumber(L, attrType);
		lua_rawseti(L, -2, 1);

		// Gets and inserts the item attribute value into the lua table
		lua_pushnumber(L, attrValue);
		lua_rawseti(L, -2, 2);

		return 1;
	}


			{ "get_attr",		item_get_attribute},

Créditos: el nub de PACI, pepe para los colegas ;)

Enlace para comentar
Compartir en otros sitios

Unirse a la conversación

Puedes publicar ahora y registrarte más tarde. Si tienes una cuenta, regístrate para publicar con su cuenta.

Guest
Responder a este tema...

×   Has pegado contenido con formato .   Eliminar formato

  Only 75 emoji are allowed.

×   Tu enlace se ha incorporado automáticamente.   Mostrar un enlace en su lugar

×   Se ha restaurado el contenido anterior. .   Borrar editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recientemente navegando por este tema   0 miembros

    • No hay usuarios registrados visitando esta página.
×
×
  • Crear nuevo...