1,482
edits
imported>Otaka |
m (Convert source tags to syntaxhighlight) |
||
| Line 16: | Line 16: | ||
=Создание простого переключателя= | =Создание простого переключателя= | ||
< | <syntaxhighlight lang="papyrus">ScriptName SimpleToggle Extends ObjectReference | ||
Bool bToggle | Bool bToggle | ||
| Line 27: | Line 27: | ||
; Undo stuff | ; Undo stuff | ||
Endif | Endif | ||
EndEvent</ | EndEvent</syntaxhighlight> | ||
'''Что нужно, чтобы этот скрипт заработал''': Прикрепите этот скрипт к кнопке или рычагу. | '''Что нужно, чтобы этот скрипт заработал''': Прикрепите этот скрипт к кнопке или рычагу. | ||
| Line 33: | Line 33: | ||
=A Quest item you can drop and pick up again and set or reset objectives and Stages.= | =A Quest item you can drop and pick up again and set or reset objectives and Stages.= | ||
< | <syntaxhighlight lang="papyrus"> | ||
Scriptname DroppableQuestObject extends ObjectReference | Scriptname DroppableQuestObject extends ObjectReference | ||
| Line 69: | Line 69: | ||
Int Property ObjectiveToHideOnDrop = -1 Auto ; Should be the same as ObjectiveToDisplayOnPickup, ideally. | Int Property ObjectiveToHideOnDrop = -1 Auto ; Should be the same as ObjectiveToDisplayOnPickup, ideally. | ||
</ | </syntaxhighlight> | ||
To use this script: attach it to the item you want to use, and set the properties accordingly, assigning the quest, Objectives, and Stages involved. For example, let's say that in the quest "StarsAndGarters", the garter belt of Wootazootamootagoota The Tense is set in stage 10 as Objective 10, and Displays Objective 20 "Place the belt on the statue", and sets stage 20 when picked up, and you want to go back to stage 10 if the player drops it. And after stage 30 (Player has put the belt on the statue) it no longer matters what happens to it. You would set your properties as follows: | To use this script: attach it to the item you want to use, and set the properties accordingly, assigning the quest, Objectives, and Stages involved. For example, let's say that in the quest "StarsAndGarters", the garter belt of Wootazootamootagoota The Tense is set in stage 10 as Objective 10, and Displays Objective 20 "Place the belt on the statue", and sets stage 20 when picked up, and you want to go back to stage 10 if the player drops it. And after stage 30 (Player has put the belt on the statue) it no longer matters what happens to it. You would set your properties as follows: | ||
| Line 84: | Line 84: | ||
=A Trigger That Detects When The Player Enters= | =A Trigger That Detects When The Player Enters= | ||
< | <syntaxhighlight lang="papyrus"> | ||
Scriptname ExampleTrigger extends ObjectReference | Scriptname ExampleTrigger extends ObjectReference | ||
| Line 93: | Line 93: | ||
EndEvent | EndEvent | ||
</ | </syntaxhighlight> | ||
'''To Make This Script Work''' | '''To Make This Script Work''' | ||
| Line 123: | Line 123: | ||
This example script cycles through a List of objects, known as a [[Formlist]], and enables them all if they are disabled, and disables them if they are enabled, each time the player character walks through a chosen trigger volume. | This example script cycles through a List of objects, known as a [[Formlist]], and enables them all if they are disabled, and disables them if they are enabled, each time the player character walks through a chosen trigger volume. | ||
If you use a [[Formlist]] of special effects, this would cause all the many special effects you have in the formlist to disappear or reappear each time you walk through the trigger volume. | If you use a [[Formlist]] of special effects, this would cause all the many special effects you have in the formlist to disappear or reappear each time you walk through the trigger volume. | ||
< | <syntaxhighlight lang="papyrus">ScriptName RamaFormListExampleScript extends ObjectReference | ||
Int iIndex | Int iIndex | ||
| Line 142: | Line 142: | ||
EndWhile | EndWhile | ||
EndIf | EndIf | ||
EndEvent</ | EndEvent</syntaxhighlight> | ||
'''To Make This Script Work''' | '''To Make This Script Work''' | ||
* This script runs on a OnTriggerEnter event, so you must create a trigger volume. See the [[Complete_Example_Scripts#A_Trigger_That_Detects_When_The_Player_Enters|script example above]] for details on this. | * This script runs on a OnTriggerEnter event, so you must create a trigger volume. See the [[Complete_Example_Scripts#A_Trigger_That_Detects_When_The_Player_Enters|script example above]] for details on this. | ||
| Line 166: | Line 166: | ||
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. | 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. | ||
< | <syntaxhighlight lang="papyrus">Scriptname LinkRefChainExample extends ObjectReference | ||
Event OnActivate(ObjectReference akActionRef) | Event OnActivate(ObjectReference akActionRef) | ||
| Line 181: | Line 181: | ||
Function PerformActionOn(ObjectReference Target) | Function PerformActionOn(ObjectReference Target) | ||
Target.MoveTo(Target, 0, 0, 16) | Target.MoveTo(Target, 0, 0, 16) | ||
EndFunction</ | EndFunction</syntaxhighlight> | ||
'''To Make This Script Work''' | '''To Make This Script Work''' | ||
| Line 199: | Line 199: | ||
* 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) | * 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. | * Use different Events freely, this event is used for simplicity and easy demonstration. | ||
< | <syntaxhighlight lang="papyrus">ScriptName MoveObjExample extends ObjectReference | ||
ObjectReference property dest auto | ObjectReference property dest auto | ||
| Line 207: | Line 207: | ||
akActionRef.TranslateToRef(dest,500) ; 500 is the speed value, it's pretty fast | akActionRef.TranslateToRef(dest,500) ; 500 is the speed value, it's pretty fast | ||
endif | endif | ||
EndEvent </ | EndEvent </syntaxhighlight> | ||
'''To Make This Script Work''' | '''To Make This Script Work''' | ||
| Line 218: | Line 218: | ||
=A Fully Functional Dwemer Button= | =A Fully Functional Dwemer Button= | ||
< | <syntaxhighlight lang="papyrus">Scriptname DwemerButtonExampleScript extends ObjectReference | ||
ObjectReference property objSelf auto hidden | ObjectReference property objSelf auto hidden | ||
| Line 235: | Line 235: | ||
Debug.MessageBox("Joy!") ;actual code for what button should do | Debug.MessageBox("Joy!") ;actual code for what button should do | ||
endif | endif | ||
EndEvent</ | EndEvent</syntaxhighlight> | ||
'''To Make This Script Work''' | '''To Make This Script Work''' | ||
| Line 247: | Line 247: | ||
=Set Quest Stage When Picked Up By Player= | =Set Quest Stage When Picked Up By Player= | ||
< | <syntaxhighlight lang="papyrus">ScriptName SetStageOnPlayerPickUp extends ObjectReference | ||
Quest property QuestToSet auto | Quest property QuestToSet auto | ||
| Line 261: | Line 261: | ||
State Taken | State Taken | ||
; Do nothing | ; Do nothing | ||
EndState</ | EndState</syntaxhighlight> | ||
=Usage of Arrays to Make Scripts Compact= | =Usage of Arrays to Make Scripts Compact= | ||
| Line 268: | Line 268: | ||
* turn their AI off and make them invisible | * turn their AI off and make them invisible | ||
I have different conditions within my level for when each of these two actions should occur. I could divide this into two scripts, but instead I wrote one script and passed a property to the script with each instance of the script to determine which aspect of the script would run. | I have different conditions within my level for when each of these two actions should occur. I could divide this into two scripts, but instead I wrote one script and passed a property to the script with each instance of the script to determine which aspect of the script would run. | ||
< | <syntaxhighlight lang="papyrus">Actor[] Property DraugrArray Auto ; Contains 30 elements filled in CK with the 30 Draugr | ||
Bool Property bEnableBeasts Auto ; Can be set from another script and/or initialized true or false | Bool Property bEnableBeasts Auto ; Can be set from another script and/or initialized true or false | ||
| Line 281: | Line 281: | ||
EndWhile | EndWhile | ||
EndIf | EndIf | ||
EndEvent</ | EndEvent</syntaxhighlight> | ||
Note that bEnableBeasts is a property so one can decide with each instance which way the script should work. One could use a FormList rather than an array or simply set one Draurg as the enable parent of the other 29 and enable/disable him, thus all the children refs simultaneously. | Note that bEnableBeasts is a property so one can decide with each instance which way the script should work. One could use a FormList rather than an array or simply set one Draurg as the enable parent of the other 29 and enable/disable him, thus all the children refs simultaneously. | ||
| Line 289: | Line 289: | ||
= A helper script with functions to get the current moonphase, sync between the two moons and day of the week = | = A helper script with functions to get the current moonphase, sync between the two moons and day of the week = | ||
< | <syntaxhighlight lang="papyrus"> | ||
Scriptname ExtendedUtility | Scriptname ExtendedUtility | ||
| Line 431: | Line 431: | ||
EndFunction | EndFunction | ||
</ | </syntaxhighlight> | ||
'''How to make this script work''' | '''How to make this script work''' | ||
| Line 672: | Line 672: | ||
This is used for the Player to feed his animal companion. The FormList is created in the CK and includes all the food (Potion & Ingredient) items I want to consider food for the animal. | This is used for the Player to feed his animal companion. The FormList is created in the CK and includes all the food (Potion & Ingredient) items I want to consider food for the animal. | ||
< | <syntaxhighlight lang="papyrus"> | ||
FormList Property FoodList Auto | FormList Property FoodList Auto | ||
Bool hasBeenFedToday = False | Bool hasBeenFedToday = False | ||
| Line 690: | Line 690: | ||
EndIf | EndIf | ||
EndEvent | EndEvent | ||
</ | </syntaxhighlight> | ||