Difference between revisions of "LlGenerateKey"
Jump to navigation
Jump to search
Line 9: | Line 9: | ||
|cat1=Examples | |cat1=Examples | ||
|cat2=Library | |cat2=Library | ||
|examples=<lsl> | |examples=In a two-prim linked-set put the following script (adding generateKey where noted) into the child-prim:<lsl>integer requestID = 0; | ||
// Add generateKey here!! | |||
default { | |||
touch_start(integer x) { | |||
llMessageLinked( | |||
LINK_ROOT, | |||
1234, | |||
"I am a request", | |||
generateKey("echo", (string)requestID++) | |||
); | |||
} | |||
link_message(integer x, integer y, string msg, key id) { | |||
if (y == 1234) | |||
llOwnerSay("Request: " + (string)id + " = " + msg); | |||
} | |||
}</lsl>And the following script in the root-prim:<lsl>default { | |||
link_message(integer x, integer y, string msg, key id) { | |||
if (y == 1234) // Echo, send straight back | |||
llMessageLinked(x, y, msg, id); | |||
} | |||
}</lsl>Simply touch the child-prim to use, enjoy! | |||
}} | }} | ||
Line 38: | Line 61: | ||
); | ); | ||
}</lsl> | }</lsl> | ||
{{LSLC|Examples}} |
Revision as of 15:38, 20 September 2008
LSL Portal | Functions | Events | Types | Operators | Constants | Flow Control | Script Library | Categorized Library | Tutorials |
Summary
Function: key generateKey( string service, string variable );
Generates a key using Type 3 (MD5) UUID generation to create a unique key using region-name, object-key, service and variable.
Returns a key The generated key
• string | service | – | The service, object, function, or whatever else this key may represent. | |
• string | variable | – | Any variable(s) relevant to the service that uniquely distinguish it. |
Examples
In a two-prim linked-set put the following script (adding generateKey where noted) into the child-prim:<lsl>integer requestID = 0;
// Add generateKey here!!
default {
touch_start(integer x) { llMessageLinked( LINK_ROOT, 1234, "I am a request", generateKey("echo", (string)requestID++) ); }
link_message(integer x, integer y, string msg, key id) { if (y == 1234) llOwnerSay("Request: " + (string)id + " = " + msg); }
}</lsl>And the following script in the root-prim:<lsl>default {
link_message(integer x, integer y, string msg, key id) { if (y == 1234) // Echo, send straight back llMessageLinked(x, y, msg, id); }}</lsl>Simply touch the child-prim to use, enjoy!
Implementation
<lsl>key generateKey(string service, string variable) {
return (key)llInsertString( llInsertString( llInsertString( llInsertString( llMD5String( "secondlife://" + llGetRegionName() + "/" + (string)llGetKey() + "/" + service + "/" + variable, 0 // This is reserved by specification, will // be increased with new/different versions. ), 8, "-" ), 13, "-" ), 18, "-" ), 23, "-" );
}</lsl>