Difference between revisions of "User:Niaht/Notes"

From the Oblivion ConstructionSet Wiki
Jump to navigation Jump to search
imported>Niaht
m
imported>Niaht
m
Line 9: Line 9:


===[[:Category:Variables|Variables]]===
===[[:Category:Variables|Variables]]===
Variables can be declared outside and inside the scope of a Block (or event handler) (Begin [BlockName]). They can only be assigned a value (Set) inside a block.
====[[Declaring_variables|Declaring Variables]]====
===== Script Global Variables =====
Variables can be set outside any block causing them to be Script Global. This means that once set to a value, they will remain set unless otherwise changed, until Oblivion is shut down.


What happens to them after that? If the block is run again, the variables will be re-set (not reset)?. If you wrap your Set in a conditional, do the variables retain their values after being set once? What happens when the game is restarted?
What about when you save your game? What happens then?
 
===== Temporary Variables =====
Declaring a variable inside a block could be called 'declaring a temporary variable', since the variable will only exist during the scope of the current invocation. This is similar to how variable scope works in traditional programming languages.
 
==== Variable Initialization ====
Variables are initialized using the [[Set]] function.
 
If don't want your variable to be reinitialized on each script invocation, wrap your assignment statements in a conditional.
short init
short myShort
Begin ''BlockName''
If ( init == 0 )
  Set myShort to 1
  Set init to 1
EndIf
 
====Variable Types====
=====[[Reference_Variables|Reference Variables]]=====
Reference variable can not be set to just any function that returns a value.
ref refValue
Set refValue to GetButtonPress
This will not work.


== Quest ==
== Quest ==

Revision as of 03:41, 27 December 2007

So far everything here mostly refers to Quest Scripts. I'm in the process of creating some testing packages, and since I just want the scripts to run at start...

Scripting

Functions

MessageBox: To display multiple message boxes in succession you must create a state machine, and check GetButtonPressed in between each messagebox call until you get a value larger than -1. Otherwise the second messagebox will override the first and kill the script.

Quirkyness can result, such as having a message box up with no mouse cursor. Use console mode to get a mouse cursor and clear the message box.

Variables

Declaring Variables

Script Global Variables

Variables can be set outside any block causing them to be Script Global. This means that once set to a value, they will remain set unless otherwise changed, until Oblivion is shut down.

What about when you save your game? What happens then?

Temporary Variables

Declaring a variable inside a block could be called 'declaring a temporary variable', since the variable will only exist during the scope of the current invocation. This is similar to how variable scope works in traditional programming languages.

Variable Initialization

Variables are initialized using the Set function.

If don't want your variable to be reinitialized on each script invocation, wrap your assignment statements in a conditional.

short init
short myShort

Begin BlockName
If ( init == 0 )
  Set myShort to 1
  Set init to 1
EndIf

Variable Types

Reference Variables

Reference variable can not be set to just any function that returns a value.

ref refValue
Set refValue to GetButtonPress

This will not work.

Quest

Blocks

GameMode

Quest Functions

StopQuest - Modifies Player? (e.g. will set a variable in the savegame if saved)