You are here

Local Variables on Stackable Items

7 posts / 0 new
Last post
Andarian
Andarian's picture
Local Variables on Stackable Items

I think I know (from thought and some limited testing) how this works, but I just wanted to ask generally to check.

If you set a local variable on an instance of a stackable item, and then merge it into a stack with items that have differing (or no) values set for that local variable, and then split it again, the variables aren't preserved. From what I've observed it looks like the value of whichever one managed to get set at the "top" of the stack keeps its value, and the rest get cleared, but you can't count on them making sense after the merge.

Is that right?

 

 

 

 

 

  • up
    50%
  • down
    50%
cozmothemagician

Not sure why you would even think about putting locals on a stacked item since they are supposed to be all the same.  If you want to store SIMILAR items in a collection, I would reccomend putting them in an appropriate container instead.   BTW, even if I knew the exact 'mechanics' of this, I could not answer as you don't specify NWN1 or NWN2.  Not trying to nit pick, but there are many quirks between the two.

  • up
    50%
  • down
    50%
ffbj
ffbj's picture

That's correct. It remembers the top one, or the last one, that went into the stack. Generally it is just accepted practice to use unstackable items to store variables for this reason. I think it is due to the way blueprints are handled. Unique ones, non-stackable, retain the variable set on them. Although I think if you sell them that wipes the variable out, as it reverts to the standard blueprint, does not maintain any variales. 

Check out my key ring map case demo: Which explores tag stacking objects in an item.

  • up
    100%
  • down
    0%
Andarian
Andarian's picture

Cozmo: If you look at the thread title, I think you may find that this is the NWN1 scripting forum. :)

  • up
    100%
  • down
    0%
Andarian
Andarian's picture

Thanks, ffbj! That's what I ended up doing. I was thinking of tailoring the fire and acid bombs to be able to put extra damage on them via a local variable, but then I realized it wouldn't work. I had implemented non-stackable versions of them as well and ended up making the modification for those items.

  • up
    50%
  • down
    50%
cozmothemagician

Thats odd.. When I looked at it earlier it looked like it was in a general forum.. or maybe I was just tired.. sorry about that

  • up
    100%
  • down
    0%
ffbj
ffbj's picture

Ah! Interesting idea. Sort of the new & improved version.

  • up
    50%
  • down
    50%