LlKeysKeyValue
Looking for the current API? Open the llKeysKeyValue reference →
Wiki description
Start an asynchronous transaction to request a number of keys from the script's Experience.
Function notes
This function will attempt to retrieve the number of keys requested but may return less if there are not enough to fulfill the full amount requested or if the list is too large. The length of the returned list is limited to 4097 characters (the success flag "1" and 4096 characters). The order keys are returned is not guaranteed but is stable between subsequent calls as long as no keys are added or removed.
The error XP_ERROR_KEY_NOT_FOUND is returned if there index given is greater than or equal to the number of keys.
Return value notes
Returns a key that can be used to identify the corresponding dataserver event to determine if this command succeeded or failed.
Caveats
- It is recommended that keys do not contain commas due to this function returning keys in CSV format.
Examples
key trans;
default
{
state_entry()
{
// retrieve the first 10 keys
trans = llKeysKeyValue(0, 10);
}
dataserver(key t, string value)
{
if (t == trans)
{
// our llKeysKeyValue transaction is done
list result = llCSV2List(value);
if (llList2Integer(result, 0) == 1)
{
llSay(0, "Keys retrieved: "+(string)llGetSubString(value, 2, -1));
}
else if (llList2Integer(result, 1) == XP_ERROR_KEY_NOT_FOUND)
{
// no more keys
llSay(0, "No more keys" );
}
else
{
// keys request failed
llSay(0, "Key-value failed to request keys: " + llGetExperienceErrorMessage(llList2Integer(result, 1)) );
}
}
}
}See also: functions
Shared wiki helpers
The original page also injects shared parameter notes, caveats or issue information through these helpers. Their conditional MediaWiki logic is not reproduced here; inspect the preserved helper source for additional material.
Template:LSL Function/KeyValue
Original shared helper source (conditional wiki logic is not evaluated)
<noinclude>{{Multi-lang|category=LSL}}</noinclude>{{LSL Injection Test}}{{#if:
{{#vardefine:p_success_desc|A boolean specifying if the transaction succeeded (1) or not (0).}}
{{#vardefine:p_error_hover|An XP_ERROR_* flag that describes why the operation failed.}}
{{#vardefine:p_error_desc|An {{CAL|LSL Integer/experience_error{{#var:lang}}|XP_ERROR_*}} flag that describes why the operation failed.}}
{{#vardefine:p_cdl_desc|A string that is a comma-deliminated list}}
{{#vardefine:p_components_desc|varies depending upon success or failure of request}}
{{#vardefine:p_{{{d2_name|}}}_hover|{{#var:p_{{{d2_name|}}}_hover}}{{{d2_hover|}}}}}
{{#vardefine:p_{{{d3_name|}}}_hover|{{#var:p_{{{d3_name|}}}_hover}}{{{d3_hover|}}}}}
{{#vardefine:p_{{{d4_name|}}}_hover|{{#var:p_{{{d4_name|}}}_hover}}{{{d4_hover|}}}}}
{{#vardefine:p_{{{dl_name|}}}_hover|{{#var:p_{{{dl_name|}}}_hover}}{{{dl_hover|}}}}}
{{#if:{{{1|}}}<noinclude>*</noinclude>|{{LSL Function/KeyValue/Key|{{{1}}}|dataserver={{{dataserver|}}}}}}}
{{#if:{{{key|}}}|{{LSL Function/KeyValue/Key|{{{key}}}|dataserver={{{dataserver|}}}}}}}
{{#if:{{{2|}}}<noinclude>*</noinclude>|{{LSL Function/KeyValue/Value|{{{2}}}|dataserver={{{dataserver|}}}}}}}
{{#if:{{{value|}}}<noinclude>*</noinclude>|{{LSL Function/KeyValue/Value|{{{value}}}|Note! This value may contain commas.|dataserver={{{dataserver|}}}}}}}
{{#vardefine:p_{{{d2_name|}}}_desc|{{#var:p_{{{d2_name|}}}_desc}}{{{d2_desc|}}}}}
{{#vardefine:p_{{{d3_name|}}}_desc|{{#var:p_{{{d3_name|}}}_desc}}{{{d3_desc|}}}}}
{{#vardefine:p_{{{d4_name|}}}_desc|{{#var:p_{{{d4_name|}}}_desc}}{{{d4_desc|}}}}}
{{#vardefine:p_{{{dl_name|}}}_desc|{{#var:p_{{{dl_name|}}}_desc}}{{{dl_desc|}}}}}
<includeonly>
{{#ifeq:{{#var:article-type}}|event||{{#if:{{#pos:{{#var:moded}}|r}}{{#pos:{{#var:moded}}|u}}||{{#vardefine:hidden-text|{{#var:hidden-text}}
{{LSLC|Dataserver{{#var:lang}}}}{{#if:{{{mode|}}}|{{LSLC|Dataserver/{{{mode}}}{{#var:lang}}}}}}
}}}}}}
</includeonly>
{{#vardefine:table_text|{{PBR}}
The string containing a comma-delimited list ({{LSLPT|cdl}}). <code>llDumpList2String([ [[integer]] {{LSLPT|success}} ] + {{LSLPT|components}});</code>
* {{LSLPT|components}} vary depending upon success or failure of request.
* Failure: <code>{{LSLPT|cdl}} = [[llDumpList2String]]([ 0, [[integer]] {{LSLPT|error}}],",")</code>
* Success: <code>{{LSLPT|cdl}} = [[llDumpList2String]]([ 1{{#if:{{{d2_type|}}}{{{d2_name|}}}|, [[{{{d2_type}}}{{#var:lang}}|{{{d2_type}}}]] {{LSLPT|{{{d2_name}}}}}{{#if:{{{d3_type|}}}{{{d3_name|}}}|, [[{{{d3_type}}}{{#var:lang}}|{{{d3_type}}}]] {{LSLPT|{{{d3_name}}}}}{{#if:{{{d4_type|}}}{{{d4_name|}}}|, [[{{{d4_type}}}{{#var:lang}}|{{{d4_type}}}]] {{LSLPT|{{{d4_name}}}}}}}}}}} ]{{#if:{{{dl_name|}}}| + {{LSLPT|{{{dl_name|}}}}})}},",")</code>
===== String Components =====
{{{!}} style="margin-left:0em;"
{{LSL DefineRow|integer|2={{CAL|LSL Integer/boolean{{#var:lang}}|success}}|3={{#var:p_success_desc}}}}
{{LSL DefineRow|integer|2={{CAL|LSL Integer/experience_error{{#var:lang}}|error}}|3={{#var:p_error_desc}}}}
{{#if:{{{d2_name|}}}{{{d2_type|}}}|{{LSL DefineRow|1={{{d2_type|}}}|2={{#if:{{{d2_subtype|}}}|{{CAL|LSL {{ucfirst:{{{d2_type|}}}}}/{{{d2_subtype|}}}{{#var:lang}}|{{{d2_name|}}}}}|{{LSL_Parameter_Link|{{{d2_name|}}}}}}}|3={{#var:p_{{{d2_name|}}}_desc}}}}
{{#if:{{{d3_name|}}}{{{d3_type|}}}|{{LSL DefineRow|1={{{d3_type|}}}|2={{#if:{{{d3_subtype|}}}|{{CAL|LSL {{ucfirst:{{{d3_type|}}}}}/{{{d3_subtype|}}}{{#var:lang}}|{{{d3_name|}}}}}|{{LSL_Parameter_Link|{{{d3_name|}}}}}}}|3={{#var:p_{{{d3_name|}}}_desc}}}}
{{#if:{{{d4_name|}}}{{{d4_type|}}}|{{LSL DefineRow|1={{{d4_type|}}}|2={{#if:{{{d4_subtype|}}}|{{CAL|LSL {{ucfirst:{{{d4_type|}}}}}/{{{d4_subtype|}}}{{#var:lang}}|{{{d4_name|}}}}}|{{LSL_Parameter_Link|{{{d4_name|}}}}}}}|3={{#var:p_{{{d4_name|}}}_desc}}}}
}}}}}}
{{#if:{{{dl_name|}}}|{{LSL DefineRow|1=list|2={{#if:{{{dl_subtype|}}}|{{CAL|LSL List/{{{dl_subtype|}}}{{#var:lang}}|{{{dl_name|}}}}}|{{LSL_Parameter_Link|{{{dl_name|}}}}}}}|3={{#var:p_{{{dl_name|}}}_desc}}}}}}
{{!}}}
}}
{{#if:{{{dataserver|}}}|
{{#vardefine:p_{{{d2_name|}}}_hover|}}
{{#vardefine:p_{{{d3_name|}}}_hover|}}
{{#vardefine:p_{{{d4_name|}}}_hover|}}
{{#vardefine:p_{{{dl_name|}}}_hover|}}
{{#vardefine:p_{{{d2_name|}}}_desc|}}
{{#vardefine:p_{{{d3_name|}}}_desc|}}
{{#vardefine:p_{{{d4_name|}}}_desc|}}
{{#vardefine:p_{{{dl_name|}}}_desc|}}
|
{{#vardefine:spec|{{#var:spec}}
* Maximum memory storage: 128 MiB
<h4>Dataserver</h4>
The [[dataserver]] callback parameters are:
* A key containing the {{LSLGC|Key/handle|handle}} returned from [[{{#var:name}}]]
* A string containing a comma-delimited list ({{LSLPT|cdl}}). <code>llDumpList2String([ [[integer]] {{LSLPT|success}} ] + {{LSLPT|components}});</code>
** {{LSLPT|components}} vary depending upon success or failure of request.
** Failure: <code>{{LSLPT|cdl}} = [[llDumpList2String]]([ 0, [[integer]] {{LSLPT|error}}],",")</code>
** Success: <code>{{LSLPT|cdl}} = [[llDumpList2String]]([ 1{{#if:{{{d2_type|}}}{{{d2_name|}}}|, [[{{{d2_type}}}{{#var:lang}}|{{{d2_type}}}]] {{LSLPT|{{{d2_name}}}}}{{#if:{{{d3_type|}}}{{{d3_name|}}}|, [[{{{d3_type}}}{{#var:lang}}|{{{d3_type}}}]] {{LSLPT|{{{d3_name}}}}}{{#if:{{{d4_type|}}}{{{d4_name|}}}|, [[{{{d4_type}}}{{#var:lang}}|{{{d4_type}}}]] {{LSLPT|{{{d4_name}}}}}}}}}}} ]{{#if:{{{dl_name|}}}| + {{LSLPT|{{{dl_name|}}}}})}},",")</code>
===== String Components =====
{{{!}} style="margin-left:0em;"
{{LSL DefineRow|integer|2={{CAL|LSL Integer/boolean{{#var:lang}}|success}}|3={{#var:p_success_desc}}}}
{{LSL DefineRow|integer|2={{CAL|LSL Integer/experience_error{{#var:lang}}|error}}|3={{#var:p_error_desc}}}}
{{#if:{{{d2_name|}}}{{{d2_type|}}}|{{LSL DefineRow|1={{{d2_type|}}}|2={{#if:{{{d2_subtype|}}}|{{CAL|LSL {{ucfirst:{{{d2_type|}}}}}/{{{d2_subtype|}}}{{#var:lang}}|{{{d2_name|}}}}}|{{LSL_Parameter_Link|{{{d2_name|}}}}}}}|3={{#var:p_{{{d2_name|}}}_desc}}}}
{{#if:{{{d3_name|}}}{{{d3_type|}}}|{{LSL DefineRow|1={{{d3_type|}}}|2={{#if:{{{d3_subtype|}}}|{{CAL|LSL {{ucfirst:{{{d3_type|}}}}}/{{{d3_subtype|}}}{{#var:lang}}|{{{d3_name|}}}}}|{{LSL_Parameter_Link|{{{d3_name|}}}}}}}|3={{#var:p_{{{d3_name|}}}_desc}}}}
{{#if:{{{d4_name|}}}{{{d4_type|}}}|{{LSL DefineRow|1={{{d4_type|}}}|2={{#if:{{{d4_subtype|}}}|{{CAL|LSL {{ucfirst:{{{d4_type|}}}}}/{{{d4_subtype|}}}{{#var:lang}}|{{{d4_name|}}}}}|{{LSL_Parameter_Link|{{{d4_name|}}}}}}}|3={{#var:p_{{{d4_name|}}}_desc}}}}
}}}}}}
{{#if:{{{dl_name|}}}|{{LSL DefineRow|1=list|2={{#if:{{{dl_subtype|}}}|{{CAL|LSL List/{{{dl_subtype|}}}{{#var:lang}}|{{{dl_name|}}}}}|{{LSL_Parameter_Link|{{{dl_name|}}}}}}}|3={{#var:p_{{{dl_name|}}}_desc}}}}}}
{{!}}}
}}
}}
<!--
{{#if:{{{nocaveats|}}}||{{#if:{{{nogroup|}}}|
{{#vardefine:caveats|{{#var:caveats}}}}
*
}}}}
{{#if:{{#var:key_stuff}}||
{{#vardefine:key_stuff|*}}
{{#vardefine:notes|{{#var:notes}}}}
}}
-->
}}<noinclude>
{| {{Prettytable}}
|-{{Hl2}}
! #var
! value
|-
{{VarPair|p_{{{1}}}_desc}}
|-
{{VarPair|p_{{{2}}}_desc}}
|-
{{VarPair|p_{{{value}}}_desc}}
|-
{{VarPair|spec}}
|-
{{VarPair|caveats}}
|-
{{VarPair|table_text}}
|}
</noinclude>{{#if:{{{dataserver|}}}|{{#var:table_text}}}}Template:LSL Function/Experience
Original shared helper source (conditional wiki logic is not evaluated)
<noinclude>{{Multi-lang|category=LSL}}</noinclude>{{LSL Injection Test}}{{#if:
{{#vardefine:notes|{{#var:notes}}
<h4>Compiling</h4>
For a script to be associated with an {{LSLGC|Experience}}...
* It must be compiled with a client that is Experience aware,
* The "Use Experience" checkbox must be checked,
* And one of the users Experience keys selected.
{{LSL Tip|Not all [[TPV]]s have this functionality.}}
}}
{{#ifeq:{{{1|}}}<noinclude>true</noinclude>|true|
{{#vardefine:header_footnote_last|{{#var:header_footnote_last}}{{PBR}}
For this {{#var:article_type}} to work, the script must be compiled into an {{LSLGC|Experience}}.{{PBR}}
}}
{{#vardefine:caveats|{{#var:caveats}}
* If you recompile a script that was previously associated with an Experience but do so with a client that lacks the ability to compile scripts into an experience the script will lose the associated Experience.
}}
}}
}}<noinclude>
{| {{Prettytable}}
|-{{Hl2}}
! #var
! value
|-
{{VarPair|header_footnote_last}}
|-
{{VarPair|spec}}
|-
{{VarPair|caveats}}
|-
{{VarPair|notes}}
|}
</noinclude>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.