Skip to content

Stack size and variables.

ReachPWReachPW Member Posts: 27
edited February 2020 in Builders - Scripting
I think variables are getting wiped from items when they become part of a stack.

I make two arrows (non-stacked) and set a local int, say "TEST" to 1.

The first arrow I pick up has this set (in mod acquire event). But the second arrow doesn't and stack size is two.

It looks like when an item becomes part of a stack all the local variables are lost. Is this true and is there any work around for this?

I can provide full example code if needed, but it's really simple

on acquire event:
object oItem = GetModuleItemAcquired();
int nTest = GetLocalInt(oItem, "TEST");
FloatingTextStringOnCreature(IntToString(nTest), oPlayer, FALSE);

First arrow is always 1, but everything after is 0

Comments

  • SherincallSherincall Member Posts: 387
    When you merge stacks A<-B, variables in A are preserved, variables in B are lost. This might be quirky, but it's been standard NWN behavior.
    With NWNX, there is a tweak that will prevent merging of stacks that have different variables:
    https://nwnxee.github.io/unified/group__tweaks.html
    (NWNX_TWEAKS_COMPARE_VARIABLES_WHEN_MERGING)
Sign In or Register to comment.