Difference between revisions of "Useful Scripts"
→+ FOSE
imported>Henning |
imported>Henning (→+ FOSE) |
||
Line 376: | Line 376: | ||
endif | endif | ||
End | End | ||
</pre> | |||
== Iterating through multiple lists == | |||
Script Type: Object | |||
;Script requires the [[Fallout Script Extender]]. | |||
This is a good technique for making simulated 2 dimension arrays in tes script | |||
There are a few technically unnecessary variables but this loop is setup to be used as part of a series. | |||
To use in series, just copy everything from ";Main Loop" to the last "EndIf". The only thing you need to change is the value of "MainList". | |||
Sorry for any errors, I'm writing this from memory | |||
<pre> | |||
scn Test2Dim | |||
; Counter vars | |||
long Count1 | |||
long Count2 | |||
; Max Count vars | |||
long MaxCount1 | |||
long MaxCount2 | |||
; Label vars | |||
short Label1 | |||
short Label2 | |||
; Lists | |||
ref MainList | |||
ref CurrentList | |||
ref CurrentRef | |||
Begin onActivate | |||
; setup counters | |||
Set Label1 To 0 | |||
Set Label2 To 1 | |||
;Main Loop | |||
Set MainList To TopLevelListHere | |||
Set Label1 To Label1 + 2 ; 2 Because its the number af labels | |||
Set Label2 To Label2 + 2 | |||
Set Count1 To 0 | |||
Set MaxCount1 To ListGetCount MainList | |||
Label Label1 | |||
Set Count2 To 0 | |||
Set CurrentList To ListGetNthForm MainList Count1 | |||
Set MaxCount2 To ListGetCount CurrentList | |||
Label Label2 | |||
Set CurrentRef To ListGetNthForm CurrentList Count2 | |||
; Use CurrentRef here | |||
If Count2 < MaxCount2 | |||
Set Count2 To Count2 + 1 | |||
GoTo Label2 | |||
EndIf | |||
If Count1 < MaxCount1 | |||
Set Count1 To Count1 + 1 | |||
GoTo Label1 | |||
EndIf | |||
End | |||
</pre> | </pre> |