int inside while loop not initialized at zero

Post » Sat Jan 04, 2014 4:33 pm

Here's a weird one for you...

Spoiler
  ;add ingredients:  i = FullIngList.Length  debug.trace(":::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: FullIngList.LENGTH == " + i)  while i    i -= 1    debug.trace("::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: FullIngList LOOP:   i == " + i + "  ing == " + (FullIngList[i] as form).getName())    int efNum    debug.trace("::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: LOOP:   efNum initialized, and == " + efNum)    int num = 4 ;since ingredients (should) always have 4 effects    while num      num -= 1      MagicEffect mf = FullIngList[i].getNthEffectMagicEffect(num)      int this = MGEFs.find(mf)      if this > 0        FullIngListX[i] = FullIngListX[i] + this * effectCodeMult[efNum]        efNum += 1        debug.trace("::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: FullIngList LOOP:   efNum += 1, and == " + efNum)        goToState(stateStrings[this])        installIngredient(FullIngList[i], num)      endif    endwhile  endWhile

Excerpt from the debug output:

Spoiler
[01/03/2014 - 11:27:23PM] ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: LOOP:   efNum initialized, and == 112[01/03/2014 - 11:27:23PM] ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: FullIngList LOOP:   efNum += 1, and == 113[01/03/2014 - 11:27:23PM] ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: FullIngList LOOP:   efNum += 1, and == 114[01/03/2014 - 11:27:23PM] ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: FullIngList LOOP:   i == 66  ing == Namira's Rot[01/03/2014 - 11:27:23PM] ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: LOOP:   efNum initialized, and == 114[01/03/2014 - 11:27:23PM] ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: FullIngList LOOP:   efNum += 1, and == 115[01/03/2014 - 11:27:23PM] ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: FullIngList LOOP:   efNum += 1, and == 116[01/03/2014 - 11:27:23PM] ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: FullIngList LOOP:   i == 65  ing == Imp Stool[01/03/2014 - 11:27:23PM] ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: LOOP:   efNum initialized, and == 116[01/03/2014 - 11:27:23PM] ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: FullIngList LOOP:   efNum += 1, and == 117[01/03/2014 - 11:27:23PM] ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: FullIngList LOOP:   i == 64  ing == White Cap[01/03/2014 - 11:27:23PM] ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: LOOP:   efNum initialized, and == 117[01/03/2014 - 11:27:23PM] ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: FullIngList LOOP:   efNum += 1, and == 118[01/03/2014 - 11:27:23PM] ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: FullIngList LOOP:   efNum += 1, and == 119[01/03/2014 - 11:27:23PM] ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: FullIngList LOOP:   i == 63  ing == Bleeding Crown[01/03/2014 - 11:27:23PM] ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: LOOP:   efNum initialized, and == 119[01/03/2014 - 11:27:23PM] ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: FullIngList LOOP:   efNum += 1, and == 120[01/03/2014 - 11:27:23PM] ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: FullIngList LOOP:   efNum += 1, and == 121[01/03/2014 - 11:27:23PM] ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: FullIngList LOOP:   i == 62  ing == Fly Amanita[01/03/2014 - 11:27:23PM] ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: LOOP:   efNum initialized, and == 121[01/03/2014 - 11:27:23PM] ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: FullIngList LOOP:   efNum += 1, and == 122[01/03/2014 - 11:27:23PM] ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: FullIngList LOOP:   efNum += 1, and == 123[01/03/2014 - 11:27:23PM] ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: FullIngList LOOP:   efNum += 1, and == 124[01/03/2014 - 11:27:23PM] ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: FullIngList LOOP:   i == 61  ing == Mudcrab Chitin[01/03/2014 - 11:27:23PM] ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: LOOP:   efNum initialized, and == 124[01/03/2014 - 11:27:23PM] ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: FullIngList LOOP:   efNum += 1, and == 125[01/03/2014 - 11:27:24PM] ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: FullIngList LOOP:   efNum += 1, and == 126[01/03/2014 - 11:27:24PM] ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: FullIngList LOOP:   efNum += 1, and == 127[01/03/2014 - 11:27:24PM] ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: FullIngList LOOP:   i == 60  ing == Salt Pile[01/03/2014 - 11:27:24PM] ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: LOOP:   efNum initialized, and == 127[01/03/2014 - 11:27:24PM] ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: FullIngList LOOP:   efNum += 1, and == 128[01/03/2014 - 11:27:24PM] Error: Array index 128 is out of range (0-127)stack:	[alias PlayerRef on quest DP_Mothership (06007E8E)].DP_CoreAlias.OnUpdate() - "DP_CoreAlias.psc" Line 1261[01/03/2014 - 11:27:24PM] ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: FullIngList LOOP:   efNum += 1, and == 129[01/03/2014 - 11:27:24PM] ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: FullIngList LOOP:   i == 59  ing == Red Mountain Flower[01/03/2014 - 11:27:24PM] ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: LOOP:   efNum initialized, and == 129[01/03/2014 - 11:27:24PM] Error: Array index 129 is out of range (0-127)stack:	[alias PlayerRef on quest DP_Mothership (06007E8E)].DP_CoreAlias.OnUpdate() - "DP_CoreAlias.psc" Line 1261[01/03/2014 - 11:27:24PM] ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: FullIngList LOOP:   efNum += 1, and == 130[01/03/2014 - 11:27:24PM] Error: Array index 130 is out of range (0-127)stack:	[alias PlayerRef on quest DP_Mothership (06007E8E)].DP_CoreAlias.OnUpdate() - "DP_CoreAlias.psc" Line 1261[01/03/2014 - 11:27:24PM] ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: FullIngList LOOP:   efNum += 1, and == 131[01/03/2014 - 11:27:24PM] ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: FullIngList LOOP:   i == 58  ing == Purple Mountain Flower[01/03/2014 - 11:27:24PM] ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: LOOP:   efNum initialized, and == 131[01/03/2014 - 11:27:24PM] Error: Array index 131 is out of range (0-127)stack:	[alias PlayerRef on quest DP_Mothership (06007E8E)].DP_CoreAlias.OnUpdate() - "DP_CoreAlias.psc" Line 1261

there is no other efNum variable defined at a higher level in my script, either.

I guess, long story short, we need to make sure to explicitly define new variables at zero to ensure they come that way?

User avatar
Marine Arrègle
 
Posts: 3423
Joined: Sat Mar 24, 2007 5:19 am

Post » Sat Jan 04, 2014 7:11 pm

It appears to me that because you do not explicitly set efNum to 0, it retains the value as set in previous iterations of the script.

User avatar
Charlotte Henderson
 
Posts: 3337
Joined: Wed Oct 11, 2006 12:37 pm


Return to V - Skyrim