Linkset Data
Linkset data is a key-value store kept in the object itself, shared by every script in the linkset. It is the usual place for an object’s own persistent state. Part of the Data Storage feature.
Concepts
- The store holds up to 128 KiB of string name:value pairs and does not use script memory
- It survives script resets, deletion of the script and cloning the object
- Each pair costs the UTF-8 length of name plus value, and 32 bytes more if protected;
llLinksetDataAvailablegives the bytes left
- Write creates or updates a pair, read returns its value, delete removes it
- Writing an empty value deletes the pair
- Writes return a result code such as
LINKSETDATA_OKorLINKSETDATA_EMEMORY - Many small keys are cheaper than reading and rewriting one large value
- Protected pairs need the same pass to read, update or delete
- The value of a protected pair is not sent in
linkset_data
- The value of a protected pair is not sent in
- Keys can be listed alphabetically and counted
llLinksetDataReseterases everything, protected pairs included- Every change raises
linkset_datain all scripts of the linkset, with the action, the name and the new value
Functions and events
integer | llLinksetDataWrite(string name, string value) |
string | llLinksetDataRead(string name) |
integer | llLinksetDataDelete(string name) |
integer | llLinksetDataWriteProtected(string name, string value, string pass) |
list | llLinksetDataFindKeys(string pattern, integer start, integer count) |
integer | llLinksetDataAvailable() |
event | linkset_data(integer action, string name, string value) |
Scripting Details
integer | llLinksetDataWrite(string name, string value)Creates or updates an unprotected key-value pair (name and value) in the linkset's datastore. Returns an integer success or failure code. |
string | llLinksetDataRead(string name)Reads and returns the string value corresponding to key name from the linkset's datastore. |
integer | llLinksetDataDelete(string name)Deletes the unprotected key-value pair specified by name from the linkset's datastore, triggering a linkset_data event. |
integer | llLinksetDataWriteProtected(string name, string value, string pass)Creates or updates a protected key-value pair (name and value) in the linkset's datastore using the passphrase pass. Returns an integer success or failure code. |
string | llLinksetDataReadProtected(string name, string pass)Reads and returns the string value of the protected key name from the linkset's datastore using the passphrase pass. |
integer | llLinksetDataDeleteProtected(string name, string pass)Deletes the protected key-value pair specified by name from the linkset's datastore using the passphrase pass, triggering a linkset_data event. |
list | llLinksetDataFindKeys(string pattern, integer start, integer count)Returns an alphabetically sorted list of up to count keys from the datastore that match the regular expression pattern, starting at index start (returns all matching keys if count < 1). |
list | llLinksetDataListKeys(integer start, integer count)Returns an alphabetically sorted list of up to count keys from the datastore, starting at index start (returns all keys if count < 1). |
integer | llLinksetDataCountKeys()Returns an integer representing the total number of unique keys stored in the linkset's datastore. |
integer | llLinksetDataCountFound(string pattern)Returns the total count of keys in the linkset datastore that match the regular expression pattern. |
list | llLinksetDataDeleteFound(string pattern, string pass)Deletes all keys in the datastore matching the regular expression pattern. Returns a list [num_deleted, num_failed_protected]. Decrypts and deletes protected keys if matching pass is provided. |
integer | llLinksetDataAvailable()Returns an integer representing the number of bytes available/remaining in the linkset's datastore. |
llLinksetDataReset()Erases all key-value pairs stored in the linkset's datastore, triggering a linkset_data event (with LINKSETDATA_RESET) in all scripts in the linkset. | |
event | linkset_data(integer action, string name, string value)Fires in all scripts in the linkset whenever the datastore has been modified via an llLinksetData function. Passes the action taken, the affected key name, and the new value. |
Example
Section titled “Example”default{ touch_start(integer num_detected) { integer count = (integer)llLinksetDataRead("touches") + 1; llLinksetDataWrite("touches", (string)count); }
linkset_data(integer action, string name, string value) { if (action == LINKSETDATA_UPDATE && name == "touches") llSetText("Touched " + value + " times", <1, 1, 1>, 1); }}Constant groups
Section titled “Constant groups”Constant groups LinksetDataAction 4LinksetDataError 6
Related
Section titled “Related”See also Feature Data StorageCategory Linkset DataSL Wiki Linkset dataPage Guide: linkset resources (reusable prims in linkset data)