Editing Scripting for Beginners

Jump to navigation Jump to search

Warning: You are not logged in. Your IP address will be publicly visible if you make any edits. If you log in or create an account, your edits will be attributed to your username, along with other benefits.

The edit can be undone. Please check the comparison below to verify that this is what you want to do, and then publish the changes below to finish undoing the edit.

Latest revision Your text
Line 35: Line 35:
  End
  End


In order to attach our script to the bobby pin form, we have to specify which type of script it is. With the exception of Result scripts, all scripts are divided up into three types (see the glossary for descriptions):
In order to attach our script to the bobby pin form, we have to specify which type of script it is. With the exception of Result scripts, all scripts are divided up into three types:


* Object
* Object
Line 115: Line 115:
Now, when the [[OnAdd]] block runs, the "if GetContainer == player" condition is checked first. If it evaluates to true, then the "ShowMessage MyMessage" line will run, and the script will then skip to the corresponding "endif" statement - the "else" condition and the code it contains will be completely skipped. However, if the first condition evaluates to false, then the second condition, "else", is checked. As I mentioned before, "else" statements basically mean "if all prior conditions returned false" - if an "else" statement is ever checked, the code within it will run and all following conditions will be skipped.
Now, when the [[OnAdd]] block runs, the "if GetContainer == player" condition is checked first. If it evaluates to true, then the "ShowMessage MyMessage" line will run, and the script will then skip to the corresponding "endif" statement - the "else" condition and the code it contains will be completely skipped. However, if the first condition evaluates to false, then the second condition, "else", is checked. As I mentioned before, "else" statements basically mean "if all prior conditions returned false" - if an "else" statement is ever checked, the code within it will run and all following conditions will be skipped.


Now our script has two possible outputs - if a bobby pin is added to the player's inventory, "MyMessage" will be shown, and if a bobby pin is added to the inventory of a container other than the player, "MyOtherMessage" will be shown. This is cool, but what if we want to have more possible outputs associated with our script. For example, what if we wanted to play a different message again (let's call it "MyDadMessage" and have it say "Hello Dad!") if a bobby pin is added to the player's father's inventory (his EditorRefID is MQDadRef)? Perhaps the most obvious approach to this would be to place a new "if" statement within the "else" statement like so:
Now our script has two possible outputs - if a bobby pin is added to the player's inventory, "MyMessage" will be shown, and if a bobby pin is added to the inventory of a container other than the player, "MyOtherMessage" will be shown. This is cool, but what if we want to have more possible outputs associated with our script. For example, what if we wanted to play a different message again (let's call it "MyDadMessage" and have it say "Hello Dad!") if a bobby pin is added to the player's father's inventory (his RefID is MQDadRef)? Perhaps the most obvious approach to this would be to place a new "if" statement within the "else" statement like so:


  ScriptName MyFirstScript
  ScriptName MyFirstScript
Line 170: Line 170:
   
   
  Begin OnAdd
  Begin OnAdd
  ...
 
    ; Do something
  End
  End


Line 312: Line 314:
'''Blocktype'''
'''Blocktype'''


There are a limited number of conditions that can be used for [[Begin|Begin/End]] blocks, such as [[OnAdd]] and [[OnDeath]]. Each of these conditions is known as a blocktype. Different types of scripts have different blocktypes available to them, so it can help to think of blocktypes as being split into several categories:
There are a limited number of conditions that can be used for [[Begin|Begin/End]] blocks, such as [[OnAdd]] and [[OnDeath]]. Each of these conditions is known as a blocktype. Different types of scripts have different blocktypes available to them, so it can help to think of blocktyps as being split into several categories:


* Effect
* Effect
Line 461: Line 463:
'''Reference Script'''
'''Reference Script'''


Scripts attached to forms that can have references are called [[reference scripts]]. Each reference to one of these forms will run its own instance of the script.
Scripts attached to forms that can have references are called [[reference scripts[[. Each reference to one of these forms will run its own instance of the script.


'''RefID'''
'''RefID'''
Line 473: Line 475:
'''Variable'''
'''Variable'''


A [[:category: variables|variable]] is something that allows you to store information in a script for later use. There are three types of variable available for use in Fallout 3 scripting, each which stores a different type of information.
A [[:category: variables|variables]] is something that allows you to store information in a script for later use. There are three types of variable available for use in Fallout 3 scripting, each which stores a different type of information.


==External Links==
==External Links==
Line 480: Line 482:


[[Category:Scripting]]
[[Category:Scripting]]
[[Category:Tutorials]]

Please note that all contributions to the Fallout3 GECK Wiki are considered to be released under the Creative Commons Attribution-ShareAlike (see GECK:Copyrights for details). If you do not want your writing to be edited mercilessly and redistributed at will, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource. Do not submit copyrighted work without permission!

Cancel Editing help (opens in new window)