Difference between revisions of "Hello World"

439 bytes added ,  21:37, 31 July 2016
no edit summary
imported>Cobalt027
imported>Cobalt027
Line 8: Line 8:


=== Steps ===
=== Steps ===
1.  Load Fallout 4 Resources
:1.  Load Fallout 4 Resources
:* Start Creation Kit
::* Start Creation Kit
:* File -> Data... -> Double Click Fallout4.esm
::* File -> Data... -> Double Click Fallout4.esm
:* Hit [OK]
::* Hit [OK]


2. Set a default namespace
:2. Set a default namespace


:When a namespace is set, the Creation Kit places all of the scripts you generate under Data/Scripts/<NameSpace>. This is handy for keeping track of your which mods various scripts support.  
::When a namespace is set, the Creation Kit places all of the scripts you generate under Data/Scripts/<NameSpace>. This is handy for keeping track of your which mods various scripts support.  


:* File -> Preferences
::* File -> Preferences
:* Scroll to the right and select the "Scripts" Tab
::* Scroll to the right and select the "Scripts" Tab
:* Within "Default namespace", enter "HW". (HW are the initials for this mod)
::* Within "Default namespace", enter "HW". (HW are the initials for this mod)
:* Hit [Apply]
::* Hit [Apply]


3. Create a Message
:3. Create a Message


:* Within the left pane of the "Object Window", Expand "Miscellaneous"
::* Within the left pane of the "Object Window", Expand "Miscellaneous"
:* Click On/Highlight "Message"
::* Click On/Highlight "Message"
:* Double Click "Blank Message" in the right pane
::* Double Click "Blank Message" in the right pane
:** ID : HelloWorld
::** ID : HelloWorld
:** Title : Hello World Title
::** Title : Hello World Title
:** Short Title : Hello Title
::** Short Title : Hello Title
:** Message Text : Hello World!
::** Message Text : Hello World!
:** Check the Box : [x] Message Box
::** Check the Box : [x] Message Box
:** Hit [OK]
::** Hit [OK]
:** Hit [YES] when asked if you wish to create a new Form
::** Hit [YES] when asked if you wish to create a new Form


4. Create a Quest
:4. Create a Quest


:The best way to introduce content into the game is by creating a new Quest that adds the content or performs various actions.
::The best way to introduce content into the game is by creating a new Quest that adds the content or performs various actions.


:* Within the left pane of the "Object Window", Expand "Character"
::* Within the left pane of the "Object Window", Expand "Character"
:* Click On/Highlight "Quest"
::* Click On/Highlight "Quest"
:* Within the right pane of the "Object Window", Right-Click the background and select "New"
::* Within the right pane of the "Object Window", Right-Click the background and select "New"
:** ID : HelloWorldQuest
::** ID : HelloWorldQuest
:** ''NOTE : "Start Game Enabled" and "Run Once" are checked. For this example, the default values are fine.''
::** ''NOTE : "Start Game Enabled" and "Run Once" are checked. For this example, the default values are fine.''
:** Hit [OK] ''NOTE : Scripts are not enabled until the quest is created''
::** Hit [OK] ''NOTE : Scripts are not enabled until the quest is created''


5. Create a Script for the Quest and inject the HelloWorld Message
:5. Create a Script for the Quest and inject the HelloWorld Message


:* Within the left pane of the "Object Window", Make sure "Character" -> "Quest" is selected  
::* Within the left pane of the "Object Window", Make sure "Character" -> "Quest" is selected  
:* Enter "HelloWorld" into the Filter box
::* Enter "HelloWorld" into the Filter box
:* Within the right pane, re-open The "HelloWorldQuest"
::* Within the right pane, re-open The "HelloWorldQuest"
:* Click on the "Scripts" Tab
::* Click on the "Scripts" Tab
:** Click [Add] => [New Script]
::** Click [Add] => [New Script]
:** Name : HelloWorldQuestScript ''NOTE : You should see your "HW" in the Namesapce''
::** Name : HelloWorldQuestScript ''NOTE : You should see your "HW" in the Namesapce''
:* When the Properties Window appears, click [Add Property]
::* When the Properties Window appears, click [Add Property]
:** Type : Message
::** Type : Message
:** Name : pHelloWorld
::** Name : pHelloWorld
:** Hit [OK]
::** Hit [OK]
:** Hit [OK] (To exit Property editor)
::** Hit [OK] (To exit Property editor)


When Properties start with the letter "p", The CK searches all objects matching the TYPE for an obvious match. Since there is
::: ''NOTE'' : When Properties start with the letter "p", The CK searches all objects matching the TYPE for an obvious match. Since there is a MessageBox named "HelloWorld", it automatically fills the property for you. If you had named the property something else, or given the message box a different ID, you would have needed to specify the specific MessageBox to inject.
a MessageBox named "HelloWorld", it automatically fills the property for you. If you had named the property something else, or
given the message box a different ID, you would have needed to specify the specific MessageBox to inject.


6. Edit the script to show the message
:6. Edit the script to show the message


:* Open up HelloWorldQuest and go to the script if you are not already there.
::* Open up HelloWorldQuest and go to the script if you are not already there.
:* Right Click [HW:HelloWorldQuestScript] and Select "Edit Source"
::* Right Click [HW:HelloWorldQuestScript] and Select "Edit Source"
:* Add the following to the bottom of the file
::* Add the following to the bottom of the file
::'' NOTE: Spacing is important. If you are pasting from this page, paste into NotePad first to eliminate format and then paste into the CK edit window.
:::'' NOTE: Spacing is important. If you are pasting from this page, paste into NotePad first to eliminate format and then paste into the CK edit window.


  Event OnInit()
  Event OnInit()
Line 77: Line 75:




:* In the Edit Script Window, goto File -> Save (''When you save, CK automatically attempts to compile the code'')
::* In the Edit Script Window, goto File -> Save (''When you save, CK automatically attempts to compile the code'')
:* Close the Script Editor
::* Close the Script Editor
:* Hit [OK] on the HelloWorldQuest window
::* Hit [OK] on the HelloWorldQuest window
:* CK -> File -> Save
::* CK -> File -> Save
:* File name: HelloWorld
::* File name: HelloWorld
:* Save as type: TES Plugin Files (*.esp)
::* Save as type: TES Plugin Files (*.esp)
:* Hit [SAVE]
::* Hit [SAVE]
:* [Optional] Exit Creation Kit
::* [Optional] Exit Creation Kit


7. Test the Mod
:7. Test the Mod


:* Startup Fallout 4
::* Startup Fallout 4
:* Hit [Play]
::* Hit [Play]
:* Hit [Mods]
::* Hit [Mods]
:* Hit [HOME] to bypass the user login
::* Hit [HOME] to bypass the user login
:* Select [HelloWorld], make sure it is checked
::* Select [HelloWorld], make sure it is checked
:* ESC to back out
::* ESC to back out
:* Hit [OK] when it detects Mod change (reloads mods)
::* Hit [OK] when it detects Mod change (reloads mods)
:* Load an existing save game or start a new game.
::* Load an existing save game or start a new game.


You should see 2 message boxes pop up. One from the Message you created and the other from the debug. If you were to change the default compile settings to release, the Debug.MessageBox() method would not work as all DEBUG methods are stripped out when the script is compiled for release into an archive. Keep this mind as you mod: You can not rely on Debug methods (specifically the message box function) as part of your mod.  
:You should see 2 message boxes pop up. One from the Message you created and the other from the debug.  


If you do not see any message boxes pop up, make sure you enabled loose files. A common mistake is to edit the wrong INI file. Make sure you edit the file under Documents/My Games/Fallout 4.
=== Lessons Learned ===
:1. Dependency Injection
 
::Papyrus works off the principles of Dependency Injection: In general, you should create objects and Inject them into your script from within the Creation Kit.
 
:2. Avoid Debug.MessageBox 
 
::When scripts are compiled into release archives, the Creation Kit will strip out all [http://www.creationkit.com/fallout4/index.php?title=Debug_Script Debug] methods such as Debug.MessageBox, Debug.TraceAndBox, etc... This example creates and injects a MESSAGE object because it is technically required to get "Hello World" to show up in a released mod.  You can not rely on Debug methods (specifically the message box function) as part of a mod.
 
=== If things aren't working ===
 
:Make sure you enabled loose files. A common mistake is to edit the wrong INI file. Make sure you edit the file under Documents/My Games/Fallout 4.
Anonymous user