SetRefInArray

From the Oblivion ConstructionSet Wiki
Jump to navigation Jump to search


A command for Pluggy

Syntax:

SetRefInArray ArrayID:long Index:long Value:ref BlockSize:long Global:short

Stores the Value at Index.

  • This can only be used to store references (works for any reference - base object, specific reference, factions, quests, etc.).
  • Useable Indexes are from 0 to (array size -1).
  • If a value is already existing at Index, then the original value is overwritten.
  • If Index >= array size , and BlockSize > 0, then the array size will be automaticly incremented by the necessary amount of BlockSize until the Index will be valid.
  • If you want to modify an array from another mod, you will need to set the Global flag to 1. If Global is 0 or unset the function will fail. If the array is protected the function will fail.

Example:

Assume two Arrays (0 and 1) with the indexes:

Index Array 0 Value Array 1 Value
Index 0 Empty Empty
Index 1 50 100
Index 2 2000 1000

then

SetRefInArray 1 0 Gold (base)
SetRefInArray 1 1 Player
SetRefInArray 0 2 Player (base)

will change them to

Index Array 0 Value Array 1 Value
Index 0 Empty 0000000F (Gold)
Index 1 50 Player
Index 2 00000007 (Player base) 1000

Blocksize example (using the original Array 0)

SetRefInArray 0 5 Gold 2
Index Array 0 Value
Index 0 Empty
Index 1 50
Index 2 2000
Index 3 Empty
Index 4 Empty
Index 5 Gold
Index 6 Empty

The array size is increased by two until the desired index is included. In this case, the array size is first increased from 3 to 5. This doesn't include index 5 (which is the 6th index as index starts at 0). It is increased again to 7, which does include index 5.