Complete Example Scripts: Difference between revisions

Jump to navigation Jump to search
imported>Evernewjoy
(Created page with " == Complete Example Scripts == * '''Script Instantiation''' Please remember that no example scripts are complete by themselves, you must create an object in your cell and a...")
 
imported>Evernewjoy
Line 9: Line 9:


And if the script has any properties, those properties must be set to actual values before script will work.
And if the script has any properties, those properties must be set to actual values before script will work.
* '''Script Name'''
You can change the name in script below to be anything you want, but the name must match what you type into the editor when you select [NEW] to make a new script.
So it is best to make a new script, give it a name, and change the name of the script examples below to match the name you typed in.
----
'''A Trigger To Activate When Player Walks Through It
'''
<source lang="papyrus">
Scriptname ExampleTrigger extends ObjectReference
Event onTriggerEnter(ObjectReference ObjRef)
        ;remove this if statement if you want
        ;other objects to activate the trigger
        ;also
if(ObjRef == game.getplayer())
Debug.MessageBox("Yippee!")
endif
endEvent
</source>
'''To Make This Script Work'''
Select an existing object in your cell
Click on the Trigger Volume button, the box with a T inside of it.
* A orange box should appear around the object you selected.
''One reason the Creation Kit is more awesome than any prior editor I've used is this feature!
If you know you need a large trigger volume, select a large object before pressing the T-box button!''
* Now edit the new orange box you created and add the script above.
* Then go in-game and walk into the space where this invisible box is.
'''Uses:'''
* Create events that depend on player positioning
* You could eliminate the player if statement above and have other actors like draugr or companions activate things as well
* Non-player triggers can be used by changing the == to a != in the script above, to do things to other actors like restoring their health or moving them around (but not affecting player if player walks through the trigger)




Anonymous user

Navigation menu