Need help with NVSE list loop script

Post » Tue May 17, 2011 2:06 am

I'm having trouble getting the below script to compile. It is supposed to go through each Faction form in the list and, if the reference belongs to that faction, store that faction into another Form List that holds a reference's current factions.
Afterwords it returns that faction to its original owner and clears the temporary faction storage list.

I put it through Cipscis's script validator but all NVSE functions are being read as errors for some reason. Everything else in the script compiles fine.

Related question: does ListGetCount get the total amount of items or the highest index in the FormList?

set iIndex to ListGetCount gcfocMainFactionsList ;gets the current item count

Label 10
if (iIndex >= 0)

set rCurrentFaction to ListGetNthForm gcfocMainFactionsList iIndex ;gets the faction at iIndex

if (rFighterOne.GetInFaction rCurrentFaction)
rCurrentFaction.ListAddReference gcfocFactionStorageListFighter1 ;stores the faction for F1
rFighterOne.RemoveFromFaction rCurrentFaction ;removes that faction temporarily
endif

set iIndex to iIndex - 1 ; go down the list
Goto 10
endif

...

set iIndex to ListGetCount gcfocFactionStorageListFighter1

Label 30
if (iIndex >= 0)

set rCurrentFaction to ListGetNthForm gcfocFactionStorageListFighter1 iIndex
ListRemoveForm gcfocFactionStorageListFighter1 rCurrentFaction ;removes that faction from the list
rFighterOne.AddToFaction rCurrentFaction 0 ;restores that faction to fighter
set iIndex to iIndex - 1 ; go down the list
Goto 30

endif

User avatar
Wayne W
 
Posts: 3482
Joined: Sun Jun 17, 2007 5:49 am

Post » Tue May 17, 2011 12:35 am

cipscis' script validator is nice, but geck powerup is better. Are you using this, which is available from newvegasnexus? It allows geck to give error messages, which for some reason is not part of the normal geck. This makes it much easier to find syntax errors. (FYI when posting code, using [ code ] tags preserves indentation and makes your code much easier to read.)
User avatar
NeverStopThe
 
Posts: 3405
Joined: Tue Mar 27, 2007 11:25 pm

Post » Tue May 17, 2011 10:54 am

cipscis' script validator is nice, but geck powerup is better. Are you using this, which is available from newvegasnexus? It allows geck to give error messages, which for some reason is not part of the normal geck. This makes it much easier to find syntax errors. (FYI when posting code, using [ code ] tags preserves indentation and makes your code much easier to read.)


I'm using the Geck PowerUp for my normal script but haven't gotten it to work with NVSE yet.

The decision to use quote instead of code was a toss up between clearly showing comments in green and preserving the indentation. I'll probably just stick with code tags from now on.

EDIT: Managed to get NVSE enabled GeckPU working without hassle. Some of the file's comments made me overly cautious about using it... that teaches me then. Thanks for the suggestion.
User avatar
Scotties Hottie
 
Posts: 3406
Joined: Thu Jun 08, 2006 1:40 am

Post » Tue May 17, 2011 1:45 pm

The decision to use quote instead of code was a toss up between clearly showing comments in green and preserving the indentation. I'll probably just stick with code tags from now on.


This forum has c-based code formatting, so you can use that to highlight comments:

set test to 42   ;// just a test comment;/*   yet  another;     comment;     stretching over several lines*/

User avatar
Devin Sluis
 
Posts: 3389
Joined: Wed Oct 24, 2007 4:22 am

Post » Tue May 17, 2011 2:53 pm

rCurrentFaction.ListAddReference gcfocFactionStorageListFighter1 ;stores the faction for F1

That looks wrong to me, since rCurrentFaction is a base form and not a reference. Won't stop the script from compiling though. Also, if I remember correctly, you should be aware when using "non-intended" types in a form list (like factions) that some NVSE list functions might not behave as you expect them to.
User avatar
HARDHEAD
 
Posts: 3499
Joined: Sun Aug 19, 2007 5:49 am

Post » Tue May 17, 2011 11:41 am

rCurrentFaction.ListAddReference gcfocFactionStorageListFighter1 ;stores the faction for F1

That looks wrong to me, since rCurrentFaction is a base form and not a reference. Won't stop the script from compiling though. Also, if I remember correctly, you should be aware when using "non-intended" types in a form list (like factions) that some NVSE list functions might not behave as you expect them to.


Thanks, but I already fixed that problem. So far that part of the script is working* as intended though I need to do more testing.

*After a few fixes. What I posted was broken.

This forum has c-based code formatting, so you can use that to highlight comments:


Ah, that's why it wasn't highlighting then. Thanks.
User avatar
Oscar Vazquez
 
Posts: 3418
Joined: Sun Sep 30, 2007 12:08 pm


Return to Fallout: New Vegas