Table of Contents

Shortnote

The description field of primitives in Second Life can be used as a decent variable storage field. While, upon a reset of a script, which may happen during a region restart, all the variables in a script get reset and data is lost, the description field can provide a persistent data storage. The description field is limited to 127 characters, which is sufficient to store variables such as flags or script settings.

Usages

Format

The variables in the primitive description are a &-separated list of keys to values bound by the equal sign.

For example, suppose two variables "test" and "start" have their values mapped to "1", respectively "now". Then the primitive description will be:

test=1&start=now

The choice of syntax tried to avoid interference with LSL types. LSL has an llList2CSV function that is able to encode a list to a comma-separated string. However, the problem with that is that vectors in LSL use the comma in order to separate the $x,y,z$ components and would thus interfere with the precedence of a comma-separated list. Since we use the equal sign (=) and the ampersand sign (&), this guarantees that we do not interfere with LSL types.

Limitations

Example Usage

Getting a variable:

wasKeyValueGet("test", llGetObjectDesc());

will return the value of the variable "test" from the primitive description.

Setting a variable:

llSetObjectDesc(wasKeyValueSet("test", "1", llGetObjectDesc()));

will set the value of the variable "test" to "1" in the primitive description.

Source

The source and usage examples may be found on the key-value data page.