"While NumRef >= 0" OR "While NumRef >

Post » Sat Jan 03, 2015 5:24 am

I have conflicting notes thats say:

While NumRef >= 0 ;<--- Because the number of refs is always 1 higher than the list of refs that start at 0.
Target = MyCell.GetNthRef(NumRef, 0x3E) as actor
NumRef -= 1

However...

While NumRef > 0 ;<--- I am seeing this in other people's scripts and on the wiki
Target = MyCell.GetNthRef(NumRef, 0x3E) as actor
NumRef -= 1

Which is correct?

User avatar
Adrian Powers
 
Posts: 3368
Joined: Fri Oct 26, 2007 4:44 pm

Post » Sat Jan 03, 2015 7:05 am

I suspect you're seeing the decrement first in those. i.e.

While NumRef ;(which implies > 0)
NumRef -= 1
Target = MyCell.GetNthRef(NumRef, 0x3E) as actor

Since 0 is a valid value, you want to include it. In your first example, won't it fail the first time, because the index is too high?
User avatar
Danii Brown
 
Posts: 3337
Joined: Tue Aug 22, 2006 7:13 am


Return to V - Skyrim