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

  • Used in the contagion project to pass formatted data from in-world objects to an attached primitive.
  • Used in the poseball system project to remember the state of the poseball as well as to elegantly pass data from the chair to the poseball.

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

  • The description field is limited to 127 bytes. Trying to write more to the description field will yield a "description overflow" error on the DEBUG_CHANNEL.
  • The variables set with these functions are case-sensitive. This means that the variable "test" is not the same as the variable "TEST" and both can thus carry different values.
  • The description of an attachment cannot be changed - it will be reset on detach.
  • Since the equal sign (=) and the ampersand sign (&) are used for the syntax, they are not allowed within variables.
  • At the time of writing, description fields do not recognize the newline character (\n) nor the pipe operator (|). When saved to the description field, they will be turned into the question mark sign (?).

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.


secondlife/persistent_storage/object_description.txt ยท Last modified: 2022/11/24 07:46 by 127.0.0.1

Access website using Tor Access website using i2p Wizardry and Steamworks PGP Key


For the contact, copyright, license, warranty and privacy terms for the usage of this website please see the contact, license, privacy, copyright.