Complete Example Scripts: Difference between revisions
Jump to navigation
Jump to search
→Complete Example Scripts
imported>Cipscis (→A Fully Functional Dwemer Button: Made capitalisation more consistent, and changed event parameter names to be in line with documentation. Also removed unneeded code handling "Self") |
imported>Evernewjoy |
||
| Line 53: | Line 53: | ||
* 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) | * 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) | ||
===Move an Object to a Specific Location Without Fade=== | |||
You can use this script to make an activator or actor move without fading out in any way (moveTo and setPosition cause fading to occur). | |||
Use this to make objects fly around or make the player move continuously to a destination without fade. | |||
''This example moves the player, for your entertainment.'' | |||
* To move something other than player, add a property of type ObjectReference and set it to the actor or activator that you want to move (I have not succeeded in moving statics, only activators and actors) | |||
* Use different Events freely, this event is used for simplicity and easy demonstration. | |||
<source lang="papyrus"> | |||
Scriptname MoveObjExample extends ObjectReference | |||
ObjectReference property dest auto | |||
Event onTriggerEnter(ObjectReference ObjRef) | |||
if(ObjRef == game.getplayer()) | |||
objRef.translateTo( | |||
dest.x,dest.y,dest.z, | |||
dest.getangleX(),dest.getangleY(),dest.getangleZ(), | |||
500) | |||
endif | |||
;500 is the speed value, and it's pretty fast | |||
endEvent | |||
</source> | |||
'''How to Make This Script Work | |||
''' | |||
* Make an XMarkerHeading object (search *All with "xmarker" filter), place it where you want the player to be moved to. | |||
* Click on an object in your cell and select the Trigger Volume button, the T with a box around it | |||
* Move the orange box to where you want the player to start their controlled movement to the XMarkerHeading destination. | |||
* Add this script above to the orange box/trigger volume that you created. | |||
* SET THE PROPERTY of the script instance, dest, to be your XMarkerHeading that you just made. | |||
This example will not work if you do not set the property as I mention just above, this is an easy thing to forget in this new and wonderful language. | |||
Get used to these basics and you will find Papyrus much more powerful than prior scripting languages. | |||
===A Fully Functional Dwemer Button=== | ===A Fully Functional Dwemer Button=== | ||