Complete Example Scripts: Difference between revisions

Jump to navigation Jump to search
m
→‎Cycle Through a List of Objects and Perform an Action on Each Object(FormLists): Got rid of extraneous var/loop/akReference = ListOfObjectsFLST.GetAt(0) As ObjectReference
imported>JustinOther
m (→‎Cycle Through a List of Objects and Perform an Action on Each Object(FormLists): Condensed to prevent carpel tunnel/standardized capitalization for legibility)
imported>JustinOther
m (→‎Cycle Through a List of Objects and Perform an Action on Each Object(FormLists): Got rid of extraneous var/loop/akReference = ListOfObjectsFLST.GetAt(0) As ObjectReference)
Line 128: Line 128:
<source lang="papyrus">ScriptName RamaFormListExampleScript extends ObjectReference
<source lang="papyrus">ScriptName RamaFormListExampleScript extends ObjectReference


Int iCurIndex
Int iIndex
Int iTotal
ObjectReference akReference
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
ObjectReference akReference


Event onTriggerEnter(ObjectReference akActionRef)
Event OnTriggerEnter(ObjectReference akActionRef)
If akActionRef == Game.GetPlayer())
If akActionRef == Game.GetPlayer())
akReference = ListOfObjectsFLST.GetAt(0) as ObjectReference ; I use ObjectReference so that IsEnabled() becomes accessible. Use Actor if you want to perform actor functions and the formlist contains actors.
iIndex = ListOfObjectsFLST.GetSize() ; Indices are offset by 1 relative to size
iTotal = ListOfObjectsFLST.GetSize() ; Initialize
While(iIndex > 0)
iCurIndex = 0 ; test index 0 entry to see if all are enabled or disabled
iIndex -= 1
If akReference.IsEnabled()
akReference = ListOfObjectsFLST.GetAt(iIndex) as ObjectReference ; Note that you must typecast the entry from the formlist using 'As'. I use ObjectReference so that IsEnabled() becomes accessible. Use Actor if you want to perform actor functions and the formlist contains actors.
While(iCurIndex < iTotal)
If akReference.IsEnabled()
akReference = ListOfObjectsFLST.GetAt(curIndex) as ObjectReference ; Note that you must typecast the entry from the formlist using "as."
akReference.Disable()
akReference.Disable()
Else ; If akReference.IsDisabled()
iCurIndex += 1
akReference.Enable()
EndWhile
EndIf
Else
While(curIndex < iTotal)
akReference = ListOfObjectsFLST.GetAt(curIndex) as ObjectReference
akReference.Enable()
curIndex += 1
EndWhile
EndWhile
EndIf
EndIf
Anonymous user

Navigation menu