You are here

Local Variables on Stackable Items

9 posts / 0 new
Last post
Andarian
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

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

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

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

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

  • up
    50%
  • down
    50%
Andarian

Another question on this: does anyone know the conditions for item stacking? Will it merge items with the same resref but different tags into a stack, or will it make separate stacks in that case? It turns out I'd "fixed" my non-stackable bomb versions to be stackable, and I don't want to go back and un-do that. CreateItem has a parameter to set a new tag, and I thought that if I could segregate all of the "special" bombs into stacks by bomb level, where the bomb level appears in the tag, that that might make it work the way I wanted.

I'll test this shortly to let folks know how it turned out.

  • up
    50%
  • down
    50%
Andarian

Yep - it works exactly as I suspected, and perfectly for what I need. Separate stacks depending on the level of the bomb (the amount of extra damage it does), all built off the same resref. Each stack has identical variables and the same "bomb level" appended tag. I even put the level in the name and description to clearly show that the stacks were different by level.

  • up
    50%
  • down
    50%