Jump to content

lua function item.get_attribute_type


Recommended Posts

  • Replies 1
  • Created
  • Last Reply

Top Posters In This Topic

Popular Days

Top Posters In This Topic

item.set_attribute_type already exists with name item.set_value.

Syntax: item.set_value(num(0,6), type, value)

item.get_attr here you have @PACI's function:

Spoiler

	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}

Syntax:

item.get_attr(num(0,6))[1] - gets the bonus type

item.get_attr(num(0,6))[2] - gets the bonus value

Link to comment
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
×
×
  • Create New...

Important Information

Terms of Use / Privacy Policy / Guidelines / We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.