Difference between revisions of "Globals"

From the Oblivion ConstructionSet Wiki
Jump to navigation Jump to search
imported>Big Brother
(→‎Notes:: I discovered ( via a nast bug ) that globals will always act as floats ( within scripts, at least ). I ran a seperate experiment to verify the claims made in the edit.)
imported>CptJoker
m (spelling, 2nd giCionToss -> giCoinToss)
Line 16: Line 16:
* It seems that, when used in scripts, global variables always act as floats regardless of what you declare them as.  This could cause issues in situations such as:
* It seems that, when used in scripts, global variables always act as floats regardless of what you declare them as.  This could cause issues in situations such as:


  set giCoinToss to GetRandomPercent / 50 ;giCionToss is a global short
  set giCoinToss to GetRandomPercent / 50 ;giCoinToss is a global short
   
   
  if( giCionToss == 1 )
  if( giCionToss == 1 )

Revision as of 16:36, 24 September 2006

A global variable is available for any script or condition to reference without being linked to a particular quest or object.

Global variables are declared in the main menu under Gameplay -> Globals


  • EditorID: The name of the variable. No spaces or special characters are allowed.
  • Variable Type: Short and Long are actually the same thing. Both are integer formats. Float is a real number format. Internally all types of global variables are stored as 32-bit floats. The technical implementation of this variable-format causes inaccuracies at very high or low values. (e.g all numbers from 2000000000 to 2000000064 are stored as 2000000000)
  • Value: The default value for the global variable. This affects the variable only when the plugin was just installed. After that the value is stored in the savegame.


Notes:

  • In almost all cases, using a global variable is unnecessary. Variables defined in quest scripts are generally used instead, and accessed via questID.varName, or getQuestVariable questID varName.
  • It seems that, when used in scripts, global variables always act as floats regardless of what you declare them as. This could cause issues in situations such as:
set giCoinToss to GetRandomPercent / 50 ;giCoinToss is a global short

if( giCionToss == 1 )
    ;do result for heads
else
    ;do result for tails
endif

In the above situation, the only time the heads result code will run is when GetRandomPercent returns exactly 50.

Variables declared in quest scripts will behave as declared and thus are safe to use in situations like the above.

See also

List of global variables