Difference between revisions of "LlReadKeyValue"
Jump to navigation
Jump to search
m (will fix this later with a subtype.) |
m (Updated result parsing in the example) |
||
Line 26: | Line 26: | ||
trans = llReadKeyValue("FOO"); | trans = llReadKeyValue("FOO"); | ||
} | } | ||
dataserver(key t, string value) | |||
dataserver(key t, string value | |||
{ | { | ||
if (t == trans) | |||
if ( | |||
{ | { | ||
// the key-value pair was successfully read | // our llReadKeyValue transaction is done | ||
if (llGetSubString(value, 0, 0) == "1") | |||
{ | |||
// the key-value pair was successfully read | |||
llSay(0, "New key-value pair value: " + llGetSubString(value, 2, -1)); | |||
} | |||
else | |||
} | { | ||
} | // the key-value pair failed to read | ||
integer error = (integer)llGetSubString(value, 2, -1); | |||
llSay(0, "Key-value failed to read: " + llGetExperienceErrorMessage(error)); | |||
} | |||
} | |||
} | |||
}</lsl>}} | }</lsl>}} |
Revision as of 11:17, 9 July 2014
LSL Portal | Functions | Events | Types | Operators | Constants | Flow Control | Script Library | Categorized Library | Tutorials |
Summary
Function: key llReadKeyValue( string k );
Start an asynchronous transaction to read the value associated with the specified key and the specified experience.
Returns the key id of the transaction.
• string | k | – | The key for the key-value pair |
The dataserver callback parameters are:
- A key containing the transaction ID returned from llReadKeyValue
- A string containing a comma-delimited list. The first item is a boolean specifying if the transaction succeeded (1) or not (0). The second item is a string with a status/error message if it failed or the value if the transaction succeeded.
Caveats
Examples
<lsl>key trans; default {
state_entry() { trans = llReadKeyValue("FOO"); } dataserver(key t, string value) { if (t == trans) { // our llReadKeyValue transaction is done if (llGetSubString(value, 0, 0) == "1") { // the key-value pair was successfully read llSay(0, "New key-value pair value: " + llGetSubString(value, 2, -1)); } else { // the key-value pair failed to read integer error = (integer)llGetSubString(value, 2, -1); llSay(0, "Key-value failed to read: " + llGetExperienceErrorMessage(error)); } } }}</lsl>