Hello World

From the Fallout4 CreationKit Wiki
Revision as of 15:19, 28 July 2016 by imported>Cobalt027 (Created page with "In this tutorial, we will make a mod that pops up a message box that says Hello World. === PreRequisites === # Install Creation Kit (From the [http://download.cdp.bethesda.ne...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

In this tutorial, we will make a mod that pops up a message box that says Hello World.

PreRequisites

  1. Install Creation Kit (From the Bethesda.net launcher)
  2. Update Fallout 4 to Enable Loose Files
  3. Update Fallout 4 to Enable Debug Logging

Steps

1. Load Fallout 4 Resources

  • Start Creation Kit
  • File -> Data... -> Double Click Fallout4.esm
  • Hit [OK]

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.
  • File -> Preferences
  • Scroll to the right and select the "Scripts" Tab
  • Within "Default namespace", enter "HW". (HW are the initials for this mod)
  • Hit [Apply]

3. Create a Message

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

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.
  • Within the left pane of the "Object Window", Expand "Character"
  • Click On/Highlight "Quest"
  • Within the right pane of the "Object Window", Right-Click the background and select "New"
    • ID : HelloWorldQuest
    • 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

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
  • Enter "HelloWorld" into the Filter box
  • Within the right pane, re-open The "HelloWorldQuest"
  • Click on the "Scripts" Tab
    • Click [Add] => [New Script]
    • Name : HelloWorldQuestScript NOTE : You should see your "HW" in the Namesapce
  • When the Properties Window appears, click [Add Property]
    • Type : Message
    • Name : pHelloWorld
    • Hit [OK]
    • 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 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

  • Open up HelloWorldQuest and go to the script if you are not already there.
  • Right Click [HW:HelloWorldQuestScript] and Select "Edit Source"
  • 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.
Event OnInit()
  pHelloWorld.Show()
  Debug.MessageBox("Hello from a Debug MessageBox!")
endEvent


  • In the Edit Script Window, goto File -> Save When you save, CK automatically attempts to compile the code