Bethesda Tutorial Papyrus Hello World
Scripts need to be attached to an editor object in a plugin in order to instantiate. The script in which you extend from determines what kind of editor object you can attach a script to in the editor. This sample shows how a message box can be displayed when a quest initializes. In the creation kit go to the Object Window and navigate to Character->Quest, right click the data grid and select New. Set the EditorID to a valid name and press ok to close the quest dialog. This is necessary because the quest needs an EditorId before you can attach scripts. Reopen the quest dialog you just created and navigate to the scripts tab. Select the Add button and double click [New Script] entry in the Add Script Window. Fill the fields out as shown.
- Name: SampleScript
- Namespace: Wiki:Tutorial
- Extends: Quest
- Documentation String: Attaches to a start game enabled quest.
Implement the OnQuestInit event by adding a debug message box. Save and compile your script.
Scriptname Wiki:Tutorial:SampleScript extends Quest
{Attaches to a start game enabled quest.}
Event OnQuestInit()
Debug.MessageBox("Hello World!")
EndEvent
Make sure you have saved your plugin at this point, enable it, and start the game. You should see a message box with the text "Hello World!". If you do not see the message box then ensure you have compiled your script in debug mode. See the release mode on the Papyrus Compiler Reference for more information.