1,482
edits
m (Convert source tags to syntaxhighlight) |
m (Convert source tags to syntaxhighlight) |
||
| Line 438: | Line 438: | ||
= Script to make an item cast a spell = | = Script to make an item cast a spell = | ||
< | <syntaxhighlight lang="Papyrus">Scriptname SpellZapScript extends ObjectReference | ||
import Utility | import Utility | ||
| Line 480: | Line 480: | ||
RegisterForSingleUpdate(PulseRate + RandomFloat(0.0, RandomRate)) | RegisterForSingleUpdate(PulseRate + RandomFloat(0.0, RandomRate)) | ||
EndEvent | EndEvent | ||
</ | </syntaxhighlight> | ||
How to make this script work: | How to make this script work: | ||
| Line 494: | Line 494: | ||
= Script for a quest with time limit = | = Script for a quest with time limit = | ||
< | <syntaxhighlight lang="Papyrus"> | ||
Scriptname LH_TimeLimitedQuest extends Quest | Scriptname LH_TimeLimitedQuest extends Quest | ||
| Line 532: | Line 532: | ||
EndIf | EndIf | ||
EndEvent | EndEvent | ||
</ | </syntaxhighlight> | ||
=Making a Cool Cut-Scene= | =Making a Cool Cut-Scene= | ||
< | <syntaxhighlight lang="Papyrus"> | ||
ScriptName Cutscene Extends ObjectReference | ScriptName Cutscene Extends ObjectReference | ||
| Line 560: | Line 560: | ||
Game.EnablePlayerControls() | Game.EnablePlayerControls() | ||
EndIf | EndIf | ||
EndEvent</ | EndEvent</syntaxhighlight> | ||
'''How to use this script''': Make a new trigger box, and then add this script to it. Make 3 XMarkers, and define them in the Properties Window. Enter your new trigger, and see your cool cut-scene! | '''How to use this script''': Make a new trigger box, and then add this script to it. Make 3 XMarkers, and define them in the Properties Window. Enter your new trigger, and see your cool cut-scene! | ||
| Line 566: | Line 566: | ||
= Script a container that only accepts certain types of items = | = Script a container that only accepts certain types of items = | ||
'''How to use this script''': Fill the FormList, AcceptedItemFLST, with only the item(s) you want the container to accept. | '''How to use this script''': Fill the FormList, AcceptedItemFLST, with only the item(s) you want the container to accept. | ||
< | <syntaxhighlight lang="Papyrus"> | ||
ScriptName ExampleContainerScript extends ObjectReference | ScriptName ExampleContainerScript extends ObjectReference | ||
| Line 578: | Line 578: | ||
EndIf | EndIf | ||
Endif | Endif | ||
EndEvent</ | EndEvent</syntaxhighlight> | ||
= Maintenance/update code which runs once per save load and shows a message when a mod is updated or first loaded = | = Maintenance/update code which runs once per save load and shows a message when a mod is updated or first loaded = | ||
*Requires Skyrim v1.6+: All event based, so no polling is necessary. For this method to work, two scripts are needed as [[OnPlayerLoadGame - Actor|OnPlayerLoadGame]] will not fire from a Quest script. | *Requires Skyrim v1.6+: All event based, so no polling is necessary. For this method to work, two scripts are needed as [[OnPlayerLoadGame - Actor|OnPlayerLoadGame]] will not fire from a Quest script. | ||
< | <syntaxhighlight lang="Papyrus">ScriptName YourQuestScript extends Quest | ||
Float fVersion | Float fVersion | ||
| Line 605: | Line 605: | ||
Event OnPlayerLoadGame() | Event OnPlayerLoadGame() | ||
QuestScript.Maintenance() | QuestScript.Maintenance() | ||
EndEvent</ | EndEvent</syntaxhighlight> | ||
*Does not require Skyrim v1.6+: Has to poll, but will work reliably and can be fit in with existing, reiterating code. | *Does not require Skyrim v1.6+: Has to poll, but will work reliably and can be fit in with existing, reiterating code. | ||
< | <syntaxhighlight lang="Papyrus">ScriptName YourQuestScript extends Quest | ||
Float fVersion | Float fVersion | ||
| Line 637: | Line 637: | ||
Return False | Return False | ||
EndIf | EndIf | ||
EndFunction</ | EndFunction</syntaxhighlight> | ||
= Summon Spell = | = Summon Spell = | ||
*The below will summon YourSummonREF from wherever they are to the player. In this example, it's dealt with by a spell, but the function could be placed and/or called elsweyr. If as a spell, be sure to set the cooldown time to about 3.0 seconds so the caster can't cast it again until it's worked itself out. | *The below will summon YourSummonREF from wherever they are to the player. In this example, it's dealt with by a spell, but the function could be placed and/or called elsweyr. If as a spell, be sure to set the cooldown time to about 3.0 seconds so the caster can't cast it again until it's worked itself out. | ||
< | <syntaxhighlight lang="Papyrus">ScriptName RepeatableSummonEffectScript extends ActiveMagicEffect | ||
Actor Property YourSummonREF Auto ; An ObjectReference will also work with the summon function | Actor Property YourSummonREF Auto ; An ObjectReference will also work with the summon function | ||
| Line 665: | Line 665: | ||
Utility.Wait(0.6) | Utility.Wait(0.6) | ||
EndWhile | EndWhile | ||
EndFunction</ | EndFunction</syntaxhighlight> | ||