Difference between revisions of "Complete Example Scripts"
Jump to navigation
Jump to search
m
→Cycle Through a List of Objects and Perform an Action on Each Object(FormLists): Defined kReference and iIndex in event body
imported>JustinOther |
imported>JustinOther m (→Cycle Through a List of Objects and Perform an Action on Each Object(FormLists): Defined kReference and iIndex in event body) |
||
Line 129: | Line 129: | ||
<source lang="papyrus">ScriptName RamaFormListExampleScript extends ObjectReference | <source lang="papyrus">ScriptName RamaFormListExampleScript extends ObjectReference | ||
Actor Property PlayerREF Auto ; Least 'expensive' way to refer to the player | Actor Property PlayerREF Auto ; Least 'expensive' way to refer to the player | ||
FormList Property ListOfObjectsFLST Auto ; see notes after script for more info on this property | FormList Property ListOfObjectsFLST Auto ; see notes after script for more info on this property | ||
Line 136: | Line 134: | ||
Event OnTriggerEnter(ObjectReference akActionRef) | Event OnTriggerEnter(ObjectReference akActionRef) | ||
If akActionRef == PlayerREF | If akActionRef == PlayerREF | ||
iIndex = ListOfObjectsFLST.GetSize() ; Indices are offset by 1 relative to size | Int iIndex = ListOfObjectsFLST.GetSize() ; Indices are offset by 1 relative to size | ||
While | While iIndex > 0 | ||
iIndex -= 1 | iIndex -= 1 | ||
ObjectReference kReference = ListOfObjectsFLST.GetAt(iIndex) As ObjectReference ; Note that you must typecast the entry from the formlist using 'As'. | |||
If | If kReference.IsEnabled() | ||
kReference.Disable() | |||
Else ; If | Else ; If kReference.IsDisabled() | ||
kReference.Enable() | |||
EndIf | EndIf | ||
EndWhile | EndWhile |