Mod:Creation Kit/Scripting AddItem Holotape Using OnMenuOpenCloseEvent

= Overview = This tutorial is designed to teach the reader to add a Mod:Creation Kit/Quest item, in this case a Mod:Creation Kit/Holotape, to the player inventory when the player opens the PipboyMenu.

There are several ways to do this. This is but one example.

The reader will learn:
 * How to set up a simple, "dummy" Quest
 * How to create a Mod:Creation Kit/Reference Alias
 * How to fill that Reference Alias with a quest script

= The Quest = The quest will need to be enabled at start, will have two stages, and will contain a reference alias with a Specific Reference Fill Type. It is not designed to show up in the player menu so it will not have a Type, Location, or a Quest Group. The script is designed to stop the quest after which time the object can be dropped by the player.

First, let's create the quest.
 * In the Mod:Creation Kit/Object Window, navigate to Character > Quests
 * On any of the quests on the right panel, Right Click > New
 * Give the quest a unique Editor ID (EDID) and a name.

For purposes of this tutorial, we've named it. Because it is a "dummy" Quest that will not show in the player inventory and will only run "behind the scenes," you can give a brief description of what the quest does for your eyes only.

The quest we are creating will be set to Start Game Enabled, and we only want the quest to run once so OnInit will not fire twice.


 * Check the boxes for Start Enabled, Run Once, and Warn on Alias Failure
 * Leave the priority at 0. While the quest has a Reference Alias, it does not have dialogue, so dialogue and AI package overrides to vanilla NPCs should not be an issue.




 * Fill in a namespace under Object Window Filter so that you can easily find it in the Mod:Creation Kit/Script Objects panel of the Object Window.

Note:


 * The Quest form only gives a few tabs when first creating a quest. You'll need to save it after initial creation in order to fully edit it.
 * For easy reference later, make use of the Object Window Filter. You'll be able to easily go to Character > Quests > YourNamespace to find your new quest.
 * If you do not have your Warnings visible in case of Alias fill failure, navigate to View > Warnings. Setting a Mod:Creation Kit/Layout color for the warnings window for  warnings, will allow you to easily find the warning and double click on it. Most warnings will pop up the form where the warning is located.
 * If "Start Game Enabled" is not also flagged to "Run Once," the OnInit Event will fire twice.

We're done with the initial set up of our quest.


 * Click "Ok" to save and close the quest to refresh it.

Quest Stages
Now let's set up the quest stages. There are two: Stage 10 and Stage 20.


 * Return to the new Quest. All tabs available for quest creation are now shown.
 * Navigate to the Quest Stages tab

The first stage is set up to run on start with a simple Debug trace for Papyrus Logging.

Stage 10:
 * Check the box for "Run on Start".
 * On the left panel Right Click > New to add a new index.
 * Fill in the index number with "10".
 * On the stage items panel Right Click > New to add the new entry to the stage index.
 * Add designer notes, such as "Start Up".
 * Add the following papyrus fragment:

Stage 10 Papyrus Fragment
The Quest Stage Fragment for this quest is as follows:


 * Click compile
 * Click "OK" to save and close the Quest to save the new fragment.

Renaming the fragment

For organizational purposes and efficient asset tracking for both the mod author and end-user, we're going to rename the fragment with our mod's unique namespace. Namespaces are subfolders within the data folder where the fragment will be output by the editor.


 * Return to your quest.
 * Navigate to Quest Stages and click on the Advanced tab.
 * click Rename Script.
 * For tutorial purposes, rename the script to  and the Namespace to.
 * Click Papyrus Fragment tab and click "Compile."
 * Click "Ok" to save and exit the Quest tab to refresh the script fragment.

Note


 * You will not have to do any renaming for the next fragment. Everything will be set up for data entry.
 * If you want the quest item to remain persistent, do not add stage 20.

Stage 20:
 * On the left panel Right Click > New to add a new index.
 * Fill in the index number with "20".
 * On the stage items panel Right Click > New to add the new entry to the stage index.
 * Add designer notes, such as "Shut down".
 * Check the box for "Complete Quest".
 * Add the following papyrus fragment:

Stage 20 Papyrus Fragment
This will complete the quest once the Quest script has run its functions.


 * Click "Compile".
 * Click "Ok" to save quest and new fragment number.



Reference Alias
Now let's set up the persistent reference.
 * Return to your quest and navigate to the Quest Aliases tab
 * Create a Reference Alias by Right Click > New Reference Alias. For purposes of this example, the name of the alias is.
 * Fill type: Specific Reference (none).
 * Check: Optional, Quest Object, Reserves Reference, Allow Reuse in Quest, Allow Disabled
 * Click "Ok" to save and exit the Reference Alias window and "Ok" on the quest to save and refresh the quest.



= The Quest Script =
 * Open the quest and Navigate to the Scripts Tab.
 * Click "Add" to attach a new script to the quest.
 * Select [New Script] and Click "Ok."
 * Give your script a new name and add it to your mod's Namespace.
 * Copy and paste the following code (rename "YourNameSpace" to the Namespace of your mod):


 * Compile your script by clicking Ctrl + S.

= Usage =
 * This is specifically for compatibility with mods that skip the prologue but should also work during debug if coc'ing directly from main menu with default character.

= Customization =
 * If you do not want a pop-up indicating the player has received the holotape, change  to  . See Mod:Creation Kit/AddItem_-_ObjectReference.


 * If you want the quest item to remain persistent and cannot be dropped and lost by the player, comment out  and do not create stage 20.