141
edits
m (Convert source tags to syntaxhighlight) |
RobinHood70 (talk | contribs) m (Convert source tags to syntaxhighlight) |
||
| Line 440: | Line 440: | ||
= 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 483: | Line 483: | ||
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 497: | Line 497: | ||
= 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 535: | Line 535: | ||
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 563: | Line 563: | ||
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 569: | Line 569: | ||
= 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 582: | Line 582: | ||
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 609: | Line 609: | ||
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 641: | Line 641: | ||
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 elsewhere. 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 elsewhere. 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 670: | Line 670: | ||
Utility.Wait(0.6) | Utility.Wait(0.6) | ||
EndWhile | EndWhile | ||
EndFunction</ | EndFunction</syntaxhighlight> | ||
= Show Gift Inventory and Identify Items Given = | = Show Gift Inventory and Identify Items Given = | ||
edits