1,482
edits
imported>Rasikko |
m (Convert source tags to syntaxhighlight) |
||
| Line 25: | Line 25: | ||
If the script is detecting a certain event, then the "do something" bit of the script should be kept separate if possible. Instead of putting some example code in there, I'd recommend a comment, like this: | If the script is detecting a certain event, then the "do something" bit of the script should be kept separate if possible. Instead of putting some example code in there, I'd recommend a comment, like this: | ||
< | <syntaxhighlight lang="papyrus">ScriptName OnPlayerActivateScript extends ObjectReference | ||
{This script detects when the object to which it is | {This script detects when the object to which it is | ||
attached is activated by the player, then does something} | attached is activated by the player, then does something} | ||
| Line 34: | Line 34: | ||
endif | endif | ||
EndEvent | EndEvent | ||
</ | </syntaxhighlight> | ||
Likewise, when a script is mainly about "doing something", if at all possible a very simple event should be used, such as OnActivate, so as not to complicate the script any further. | Likewise, when a script is mainly about "doing something", if at all possible a very simple event should be used, such as OnActivate, so as not to complicate the script any further. | ||
| Line 71: | Line 71: | ||
This script, which is attached to a trigger box, advances the quest stage to 99 once if the stage is less than 99 when the player, and only when the player, bumps into it: | This script, which is attached to a trigger box, advances the quest stage to 99 once if the stage is less than 99 when the player, and only when the player, bumps into it: | ||
< | <syntaxhighlight lang="papyrus">Scriptname AAMyTriggerBoxAdvanceQuestToStage99 extends ObjectReference | ||
Event OnTriggerEnter(ObjectReference akActionRef) | Event OnTriggerEnter(ObjectReference akActionRef) | ||
| Line 81: | Line 81: | ||
EndEvent | EndEvent | ||
Quest Property AAMyQuest Auto</ | Quest Property AAMyQuest Auto</syntaxhighlight> | ||
--[[User:David Brasher|David Brasher]] 19:21, 12 May 2012 (EDT) | --[[User:David Brasher|David Brasher]] 19:21, 12 May 2012 (EDT) | ||
--[[User:Scrivener07|Scrivener07]] 03:08, 16 May 2012 (EDT) Seems very specific to a certain quest. Ill take a shot at making it more vague :) Same script with variables. | --[[User:Scrivener07|Scrivener07]] 03:08, 16 May 2012 (EDT) Seems very specific to a certain quest. Ill take a shot at making it more vague :) Same script with variables. | ||
< | <syntaxhighlight lang="papyrus">Event OnTriggerEnter(ObjectReference akActionRef) | ||
if(akActionRef == Game.GetPlayer()) | if(akActionRef == Game.GetPlayer()) | ||
If AdvQuest.GetStage()< PreReqStage | If AdvQuest.GetStage()< PreReqStage | ||
| Line 95: | Line 95: | ||
Quest Property AdvQuest Auto | Quest Property AdvQuest Auto | ||
Int Property PreReqStage Auto | Int Property PreReqStage Auto | ||
Int Property AdvStageTo Auto</ | Int Property AdvStageTo Auto</syntaxhighlight> | ||
<br> | <br> | ||
Example scripts are only useful when they are very specific and the reader can clearly see what the parts are that need to be changed to apply to his or her mod. Most of the example scripts on this wiki are too vague and general to be used by non-professionals who just work with computers as a hobby. You are welcome to add all the example scripts in your format that you want to the wiki pages and discussion pages, put please do not edit any of my scripts I post in discussion pages. They are designed for laymen like myself and are more readable for them.--[[User:David Brasher|David Brasher]] 21:02, 24 May 2012 (EDT) | Example scripts are only useful when they are very specific and the reader can clearly see what the parts are that need to be changed to apply to his or her mod. Most of the example scripts on this wiki are too vague and general to be used by non-professionals who just work with computers as a hobby. You are welcome to add all the example scripts in your format that you want to the wiki pages and discussion pages, put please do not edit any of my scripts I post in discussion pages. They are designed for laymen like myself and are more readable for them.--[[User:David Brasher|David Brasher]] 21:02, 24 May 2012 (EDT) | ||
| Line 107: | Line 107: | ||
This script disables the questgiver if his quest is finished (if it is at stage 99.) It is placed on a trigger zone at the city gate which is out of sight of the questgiver, so that he won't vanish in front of your eyes. | This script disables the questgiver if his quest is finished (if it is at stage 99.) It is placed on a trigger zone at the city gate which is out of sight of the questgiver, so that he won't vanish in front of your eyes. | ||
< | <syntaxhighlight lang="papyrus">Scriptname AAMyQuestgiverDisableSCRIPT extends ObjectReference | ||
Event OnTriggerEnter(ObjectReference akActionRef) | Event OnTriggerEnter(ObjectReference akActionRef) | ||
| Line 119: | Line 119: | ||
Actor Property AAMyQuestgiver Auto | Actor Property AAMyQuestgiver Auto | ||
Quest Property AAMyQuest Auto</ | Quest Property AAMyQuest Auto</syntaxhighlight> | ||
--[[User:David Brasher|David Brasher]] 19:55, 12 May 2012 (EDT) | --[[User:David Brasher|David Brasher]] 19:55, 12 May 2012 (EDT) | ||
| Line 146: | Line 146: | ||
::Make a Story Managed quest (CraftItem) and insert this script: | ::Make a Story Managed quest (CraftItem) and insert this script: | ||
< | <syntaxhighlight lang="papyrus"> | ||
Event OnStoryCraftItem(ObjectReference akBench, Location akLocation, Form akCreatedItem) | Event OnStoryCraftItem(ObjectReference akBench, Location akLocation, Form akCreatedItem) | ||
if akCreatedItem == YourItemForm | if akCreatedItem == YourItemForm | ||
| Line 152: | Line 152: | ||
endif | endif | ||
endEvent | endEvent | ||
</ | </syntaxhighlight> | ||
::[[User:Templar-von-Midgard|Templar-von-Midgard]] ([[User talk:Templar-von-Midgard|talk]]) | ::[[User:Templar-von-Midgard|Templar-von-Midgard]] ([[User talk:Templar-von-Midgard|talk]]) | ||
| Line 162: | Line 162: | ||
==Quest Mod: Check Whether Prerequisite Quest is Completed on Install== | ==Quest Mod: Check Whether Prerequisite Quest is Completed on Install== | ||
I'm making a quest mod that adds a quest to the game which follows up on one of the vanilla quest lines. If the player hasn't yet completed that quest, then my quest should trigger when they do; but I figured that a nice bit of functionality to add would be to check whether the prerequisite quest is already completed upon mod install, and then start my quest if it is. I thought this problem might be similar to the Maintenance Code example on this page, and wrote it like so: | I'm making a quest mod that adds a quest to the game which follows up on one of the vanilla quest lines. If the player hasn't yet completed that quest, then my quest should trigger when they do; but I figured that a nice bit of functionality to add would be to check whether the prerequisite quest is already completed upon mod install, and then start my quest if it is. I thought this problem might be similar to the Maintenance Code example on this page, and wrote it like so: | ||
< | <syntaxhighlight lang="papyrus">ScriptName MyQuest Extends Quest Hidden | ||
;***fragments and stuff*** | ;***fragments and stuff*** | ||
| Line 182: | Line 182: | ||
endif | endif | ||
endEvent | endEvent | ||
</ | </syntaxhighlight> | ||
The OnInit() event is firing, and the prerequisite quest check works correctly, as both Debug notifications appear on the screen. The quest, however, does not start. In fact, it is broken: no "quest started" notification appears, and the quest is not in the journal, AND using setstage from the console to try to start the quest doesn't cause the notification to appear or the quest to start in the journal - although sqs at the console does mark the stage just set as completed. The quest will only begin to proceed as it should when the player interacts with one of the quest NPCs and uses a dialogue option that calls GetOwningQuest().SetStage(), at which point the journal entry appears in the player journal, minus any objectives that were given before the stage just set. Removing the above code allows the quest to be launched with "setstage MyModQuest 0" from the console, and it works normally. | The OnInit() event is firing, and the prerequisite quest check works correctly, as both Debug notifications appear on the screen. The quest, however, does not start. In fact, it is broken: no "quest started" notification appears, and the quest is not in the journal, AND using setstage from the console to try to start the quest doesn't cause the notification to appear or the quest to start in the journal - although sqs at the console does mark the stage just set as completed. The quest will only begin to proceed as it should when the player interacts with one of the quest NPCs and uses a dialogue option that calls GetOwningQuest().SetStage(), at which point the journal entry appears in the player journal, minus any objectives that were given before the stage just set. Removing the above code allows the quest to be launched with "setstage MyModQuest 0" from the console, and it works normally. | ||
| Line 196: | Line 196: | ||
The script that works in my case is this: | The script that works in my case is this: | ||
< | <syntaxhighlight lang="papyrus">Bool Property bEnableStuff Auto | ||
Float Property fHourToDisable Auto ; Desired enable time/18.0 for example's sake | Float Property fHourToDisable Auto ; Desired enable time/18.0 for example's sake | ||
Float Property fHourToEnable Auto ; Desired enable time/6.0 for example's sake | Float Property fHourToEnable Auto ; Desired enable time/6.0 for example's sake | ||
| Line 225: | Line 225: | ||
EndIf | EndIf | ||
EndFunction | EndFunction | ||
</ | </syntaxhighlight> | ||
==Enabling ReferenceAliases using an array== | ==Enabling ReferenceAliases using an array== | ||
< | <syntaxhighlight lang="papyrus"> | ||
Int i = 0 | Int i = 0 | ||
Int MyArrayLength = myAliasArray.length | Int MyArrayLength = myAliasArray.length | ||
| Line 239: | Line 239: | ||
debug.trace("Iterating:" + i) | debug.trace("Iterating:" + i) | ||
EndWhile | EndWhile | ||
</ | </syntaxhighlight> | ||
Why? | Why? | ||