Complete Example Scripts: Difference between revisions
Jump to navigation
Jump to search
a linked ref version of the cycling through formlist example
imported>Fg109 |
imported>Fg109 (a linked ref version of the cycling through formlist example) |
||
| Line 165: | Line 165: | ||
* Use enable/disable to make a whole bunch of special effect objects (they start with FX in editor) appear or disappear | * Use enable/disable to make a whole bunch of special effect objects (they start with FX in editor) appear or disappear | ||
Enjoy! | Enjoy! | ||
=== Cycle Through a List of Objects and Perform an Action on Each Object(Linked Ref Chain) === | |||
This script will cycle through all the references in a linked ref chain and perform an action on each of them. In this example, the action would be to move each reference up by 16 units when you activate any one of them. Basically, it's the same thing as the FormList version, except you create a linked ref chain instead of a FormList. | |||
<source lang="papyrus">Scriptname LinkRefChainExample extends ObjectReference | |||
Event OnActivate(ObjectReference akActionRef) | |||
if (akActionRef == Game.GetPlayer()) | |||
PerformActionOn(Self) | |||
ObjectReference TempRef = GetLinkedRef() | |||
while (TempRef && TempRef != Self) | |||
PerformActionOn(TempRef) | |||
TempRef = TempRef.GetLinkedRef() | |||
endwhile | |||
endif | |||
EndEvent | |||
Function PerformActionOn(ObjectReference Target) | |||
Target.MoveTo(Target, 0, 0, 16) | |||
EndFunction</source> | |||
'''To Make This Script Work''' | |||
* This script runs off an OnActivate event, so you must be able to activate the object this script is attached to. | |||
** You can change the OnActivate to whatever you wish to fire off the action. | |||
* You need to create a linked ref chain. | |||
** If you don't know how to create a linked ref to another object, read [[http://www.creationkit.com/Bethesda_Tutorial_Encounters#Default_Master_Package_and_Linked-Refs|this]]. | |||
** A linked ref chain is basically an object that has a linked ref, which has its own linked ref, which also has its own linked ref, etc. | |||
* Remember to attach this script to the first object in the linked ref chain | |||
** If your linked ref chain links back to itself, then you could put this script on each of the objects | |||
===Move an Object to a Specific Location Without Fade=== | ===Move an Object to a Specific Location Without Fade=== | ||