Difference between revisions of "Adding an Options Menu"

181 bytes added ,  07:08, 24 December 2008
m
Proofed and edited, added paragraph about variable names
imported>Cipscis
m (Just realised this page has its own discussion page...)
imported>Cipscis
m (Proofed and edited, added paragraph about variable names)
Line 1: Line 1:
<p>This tutorial is a Work in Progress.  If you have any feedback or suggestions, please leave a comment in the discussion page.</p>
<p>This tutorial is a Work in Progress.  If you have any feedback or suggestions, please leave a comment in the discussion page.</p>
<p>I'm assuming that anybody reading this is familiar enough with the GECK that I can ignore things like how to make a new quest, and can instead concentrate on the scripting side of things.</p>
<p>I'm assuming that anybody reading this is familiar enough with the GECK that I can ignore things like how to make a new quest, and can instead concentrate on the scripting side of things.</p>


Line 9: Line 10:
<ul>
<ul>
<li>
<li>
Analogue settings - Changing the value of a setting
Analogue settings - Settings with many possible values
</li>
</li>
<li>
<li>
Digital settings - Turning a feature on or off
Digital settings - Settings with two possible values - on or off
</li>
</li>
</ul>
</ul>
<p>Each of these settings utilises a slightly different menu structure, although they can both be incorporated into the same Options Menu.</p>
<p>Each of these settings utilises a slightly different menu structure, although they can both be incorporated into the same Options Menu.</p>


<h2>Declaring Our Variables</h2>
<h2>Declaring Our Variables</h2>


<p>The first step in making these settings editable is to define them in a "Variable Reservoir" Quest Script.  A Variable Reservoir script, or VR script is a script that contains no Begin/End blocks, but consists entirely of variable declarations.  This example VR script, which is attached to the "Start Game Enabled" quest "ExampleVariableReservoirQuest", will be used in this tutorial:</p>
<p>The first step in making these settings editable is to define them in a "Variable Reservoir Quest Script" or "VR script".  A VR script is a script that contains no Begin/End blocks, but consists entirely of variable declarations.  This example VR script, which is attached to the "Start Game Enabled" quest "ExampleVariableReservoirQuest", will be used in this tutorial:</p>


<pre>ScriptName ExampleVariableReservoirSCRIPT
<pre>ScriptName ExampleVariableReservoirSCRIPT
Line 37: Line 39:


<p>Note that it consists entirely of variable declarations, and will never actually run.  That means that these variables need some method of being initialised to their default values - at the moment they are all 0.</p>
<p>Note that it consists entirely of variable declarations, and will never actually run.  That means that these variables need some method of being initialised to their default values - at the moment they are all 0.</p>
<p>Keep in mind that your variables should be named according to their function.  The variable names I have used here were chosen to illustrate the type of setting they are used for, and are not practical.</p>


<h2>Initialising Our Variables</h2>
<h2>Initialising Our Variables</h2>


<p>To initialise these variables, we are going to add a result script to Stage 1 of ExampleVariableReservoirQuest.  A quest result script is different from regular scripts in that it can't declare any variables of its own, and it doesn't contain any Begin/End blocks.  Instead, a quest result script will run once when its quest reaches the stage that it is attached to, provided that the conditions assigned to it evaluate to true.</p>
<p>To initialise these variables, we are going to add a result script to Stage 1 of our VR quest.  A result script is different from regular scripts in that it can't declare any variables of its own, and it doesn't contain any Begin/End blocks.  Instead, a quest result script will run once when its quest reaches the stage that it is attached to, provided that the conditions assigned to it evaluate to true.</p>
 
<p>This is the result script that would used to initialise the variables in ExampleVariableReservoirSCRIPT:</p>
<p>This is the result script that would used to initialise the variables in ExampleVariableReservoirSCRIPT:</p>


Line 49: Line 54:
set ExampleVariableReservoirQuest.sAnalogueSetting2 to 5</pre>
set ExampleVariableReservoirQuest.sAnalogueSetting2 to 5</pre>


<p>Note that, even though sDigitalSetting2 initialises to 0 anyway, we have set it to 0 in this result script.  This ensures that a "Set to Defaults" option can be included in the Options Menu that can set or reset all settings to their default values with a simple "SetStage ExampleVariableReservoirQuest 1" command.</p>
<p>Note that, even though variables initialise to 0, we have set sDigitalSetting2 to 0 in this result script.  This ensures that a "Set to Defaults" option can be included in the Options Menu that can set or reset all settings to their default values with a simple "SetStage ExampleVariableReservoirQuest 1" command.</p>
<p>Of course, we need some way in which to run this result script initially - as it will not be run until ExampleVariableReservoirQuest reaches Stage 1.  Attaching the result script to Stage 0 (which quests default to when they first start running) won't work, we need to actually use "SetStage ExampleVariableReservoirQuest 1" somewhere.</p>
 
<p>Of course, we need some way in which to run this result script initially - as it will not be run until our VR quest reaches Stage 1.  Attaching the result script to Stage 0 (which quests default to when they first start running) won't work, we need to actually use "SetStage ExampleVariableReservoirQuest 1" somewhere.</p>
 
<p>To do this, we will create another "Start Game Enabled" quest, this time in the interest of initialising our variables.  The quest script attached to ExampleInitQuest will look like this:</p>
<p>To do this, we will create another "Start Game Enabled" quest, this time in the interest of initialising our variables.  The quest script attached to ExampleInitQuest will look like this:</p>


Anonymous user