User talk:Haama/Test

From the Oblivion ConstructionSet Wiki
Jump to navigation Jump to search

Usage[edit source]

Record variables are used to store any FormID. For instance,

set pItem to Apple
player.AddItem pItem 1

is the same as player.AddItem Apple 1 and player.AddItem 0003365D 1.

Record variables can only be used in scripts, and like other script variables they need to be declared:

ref pItem
ref pItem2

and can be set using the Set command

set pItem to Apple

Their greatest use is in conjunction with Reference Variable Functions, which return FormIDs. For example, placing this line on an item's script

set pOwner to GetContainer

returns the FormID of the reference which has the item. ...

some stuff on base vs. ref

  • which functions return which
  • where they can be used
  • when a mod is removed, any ref var pointing to it's base items will be set to 0
    • haven't tested placed references and am assuming the same is true of other base objects (spells, quests, etc.)

Record Variable vs. Reference Variable[edit source]

While called a reference variable in the CS and historically, the more accurate term is record variable. The reasons for the change can be found here. In brief, a reference/record variable can refer to both Base Object FormIDs/Records and specific Reference FormIDs/Records. While it can hold both, they can't be used interchangeably for function flags. For instance, if a record variable is set to a Reference and used for AddItem the script will stall:

ref pRef
...
set pRef to MothersHeadRef
player.AddItem pRef 1

AddItem needs a Base Object record variable to work:

ref pRef
...
set pRef to DarkMothersHead
player.AddItem pRef 1

This distinction is very important, so we reserve the term Reference for objects in the game world with a specific Reference FormID, and use record instead of reference variables.

Keep in mind that the term reference variable has been used for the last two years. There are still many pages on the wiki that use "reference" when "record" is meant. There are some rules of thumb to know which is which

  • For all functions
    • The flag before a function using a dot always requires a Reference record
  • If it's an OBSE function
    • All flags, following the function, that take a record variable require a Base Object record.
  • If it's a vanilla function
    • All flags, following the function, that take a record variable require a Base Object record. The exceptions are fairly obvious (i.e., GetInSameCell) so use your judgement.

Finally, please help by updating the wiki to reflect this change. If you're writing a new article please use this terminology. You can also help by updating the function pages to the syntax as found on Activate.