Jump to content
Dragonslayer

[C++] Get attr, Set attr

Recommended Posts

Archivo: questlua_item.cpp

 

Antes de meter esto, quiero que sepais que item.set_value = item.set_attr.

	int item_get_attr(lua_State* L)
	 {
	  LPITEM item = CQuestManager::instance().GetCurrentItem();
	 
	  if(!lua_isnumber(L,1) || !item)
	  {
	   return 0;
	  }
	 
	  int bonus = lua_tonumber(L,1);
	 
	  if(bonus < 0 || bonus > 6)
	  {
	   return 0;
	  }
	 
	  TPlayerItemAttribute attr = item->GetAttribute(bonus);
	  lua_pushnumber(L,attr.bType);
	  lua_pushnumber(L,attr.sValue);
	  return 2;
	 }
	 
	int item_set_attr(lua_State* L)
	 {
	  LPITEM item = CQuestManager::instance().GetCurrentItem();
	  
	  if (!lua_isnumber(L,1)||!lua_isnumber(L,2)||!lua_isnumber(L,3)||!item)
	  {
	   lua_pushnumber(L,0);
	   return 1;
	  }
	  
	  int bonus = lua_tonumber(L,1);
	  if (bonus <0 || bonus > 6)
	  {
	   lua_pushnumber(L,0);
	   return 1;
	  }
	  
	  item->SetForceAttribute(bonus,lua_tonumber(L,2),lua_tonumber(L,3));
	  lua_pushnumber(L,1);
	  return 1;
	}
			{ "get_attr",		 item_get_attr },
			{ "set_attr",		 item_set_attr },

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

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


  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...