Skip to content

Item Property Removal and price comparison

DJ_WoWDJ_WoW Member Posts: 51
edited February 2019 in Builders - Scripting
Gooday all,

I am working on a crafting system and I need to loop through the Item Properties and remove a specified Item Property before adding the new Item Property with value. This is what I have. When I compare the two Values in iStartCost and iEndCost it is clear that the Item Property has not been remove. Am I missing a step here?

int iStartCost = GetGoldPieceValue(oCopy);

itemproperty  ipLoop, ipType;

ipLoop = GetFirstItemProperty(oCopy);

 while (GetIsItemPropertyValid(ipLoop))

      {if GetItemPropertyType(ipLoop)==ITEM_PROPERTY_ENHANCEMENT_BONUS)

         {RemoveItemProperty(oCopy, ipLoop);}

    ipLoop = GetNextItemProperty(oCopy);

       }

REM: I add new Item Property to oCopy and compare prices.

int iEndCost = GetGoldPieceValue(oCopy);


Thank you for your time,
DJ-WoW

Comments

  • NeverwinterWightsNeverwinterWights Member Posts: 339
    I do see one typo:

    {if GetItemPropertyType(ipLoop)==ITEM_PROPERTY_ENHANCEMENT_BONUS)

    should be:

    {if (GetItemPropertyType(ipLoop)==ITEM_PROPERTY_ENHANCEMENT_BONUS)
  • JapualtahJapualtah Member Posts: 165
    Changes to objects don't apply before the end of the script, so whatever you with properties won't reflect before your script finishes.

    A workaround I frequently use is to call an ExecuteScript from the script which needs to modify an object. The property, in your case, will get removed at the end of the ExecuteScript and you now deal with the object accordingly in your first script.
  • DJ_WoWDJ_WoW Member Posts: 51
    Gooday to ya,

    Wanted to thank you for your informative reply. I figured it might work like destroying an object which occurs at the end of a script also.

    Greatly appreciated,

    DJ-Wow
Sign In or Register to comment.