Difference between revisions of "Category:LSL Key"

From Second Life Wiki
Jump to navigation Jump to search
m
Line 2: Line 2:
{{LSL Header}}{{LSLC|}}{{LSLC|Types}}
{{LSL Header}}{{LSLC|}}{{LSLC|Types}}


A key is a unique identifier in Second Life (often referred to as a UUID) for anything mostly, be it a prim, avatar, texture, etc.
A key is a unique identifier in Second Life for anything mostly, be it a prim, avatar, texture, etc.
 
You may see key referred to as UUID, UID, "Asset UUID", or "asset-ID."


The key itself is formed of hexidecimal characters (a-f and 0-9) and each section of the key is broken up by dashes.
The key itself is formed of hexidecimal characters (a-f and 0-9) and each section of the key is broken up by dashes.
Line 9: Line 11:
<pre>"a822ff2b-ff02-461d-b45d-dcd10a2de0c2"</pre>
<pre>"a822ff2b-ff02-461d-b45d-dcd10a2de0c2"</pre>


When passed as the parameter for a {{LSLGC|Conditional|conditional}} it only evaluates true if it is a valid key and not [[NULL_KEY]]. You can use this to detect if an arbitrary string is a valid key as follows:
 
'''Getting a Key'''
 
There are several ways to acquire the key of something:<br />
1) Having someone supply it to you;<br />
2) Using a native LSL function such as llGetKey, etc.<br />
3) In your inventory, right-clicking over something and choosing "Copy Asset UUID." Note this will only work on items that you have full permissions to.
 
 
'''Converting Keys'''
 
When a key is supplied to you as a text string, you convert it to the key data type like this:
 
(key)"a822ff2b-ff02-461d-b45d-dcd10a2de0c2";
 
 
'''Testing for a valid key'''
 
To test for a valid key, just do this:
 
<pre>if(uuid){
      //do something
      }
</pre>
 
if(uuid) will only return true if it is supplied a key that is both (A) valid, and (B) NOT a  NULL_KEY.
 
Tip! In techy talk, this method is called "passing it as the parameter for a {{LSLGC|Conditional|conditional}}"
 
Here is an example of how to build a function around this:


<lsl>
<lsl>

Revision as of 10:56, 13 July 2008

A key is a unique identifier in Second Life for anything mostly, be it a prim, avatar, texture, etc.

You may see key referred to as UUID, UID, "Asset UUID", or "asset-ID."

The key itself is formed of hexidecimal characters (a-f and 0-9) and each section of the key is broken up by dashes.

An example key:

"a822ff2b-ff02-461d-b45d-dcd10a2de0c2"


Getting a Key

There are several ways to acquire the key of something:
1) Having someone supply it to you;
2) Using a native LSL function such as llGetKey, etc.
3) In your inventory, right-clicking over something and choosing "Copy Asset UUID." Note this will only work on items that you have full permissions to.


Converting Keys

When a key is supplied to you as a text string, you convert it to the key data type like this:

(key)"a822ff2b-ff02-461d-b45d-dcd10a2de0c2";


Testing for a valid key

To test for a valid key, just do this:

if(uuid){
      //do something
      }

if(uuid) will only return true if it is supplied a key that is both (A) valid, and (B) NOT a NULL_KEY.

Tip! In techy talk, this method is called "passing it as the parameter for a conditional"

Here is an example of how to build a function around this:

<lsl> integer isKey(key in) {

   if(in) return 2;
   return (in == NULL_KEY);

} </lsl>