Skip to content
lsl.devlsl.devLSL Dev

llCreateKeyValue

functionRequires an experience
Function syntax
key llCreateKeyValue(
  1. string k,// Unique key name for the key-value pair.
  2. string v// Value for the key-value pair (maximum 2047 characters, or 4095 characters if using Mono).
);
Returns
key
Energy
10

Start an asynchronous transaction to create a key-value pair associated with the script’s Experience using the given key (k) and value (v).

If the key already exists the dataserver will return a failure along with the error XP_ERROR_STORAGE_EXCEPTION.

As of Jan 1, 2016 maximum bytes is 1011 for key and 4095 for value for both LSO and Mono scripts.

Returns a key that can be used to identify the corresponding dataserver event to determine if this command succeeded or failed.

How to use
key result = llCreateKeyValue("", "");
  • It is recommended that keys do not contain commas due to llKeysKeyValue returning keys in CSV format.
Example 1
key trans;
default
{
touch_start(integer total_number)
{
trans = llCreateKeyValue("FOO", "BAR");
}
dataserver(key t, string value)
{
if (t == trans)
{
// our llCreateKeyValue transaction is done
integer result = (integer)llGetSubString(value, 0, 0);
if (result == 1)
{
// the key-value pair was successfully created
11 collapsed lines
llSay(0, "New key-value pair was created");
}
else
{
// the key-value pair was not created
integer error = (integer)(llGetSubString(value, 2, -1));
llSay(0, "Key-value failed to create: " + llGetExperienceErrorMessage(error));
}
}
}
}
Original wiki source

Some wiki templates and tables need their original context. View this article on the Second Life Wiki. Technical wording and examples are retained from the source; historical guidance may differ from current behavior.