Key
The key
type is a specialized
string, a unique
identifier that can be used to reference
objects,
inventory items and
agents in
Second Life.
Sometimes also referred to as
UUID (Universal Unique IDentifier), UID, or
asset-ID, a key can be represented as a
string of
hexadecimal numbers in the format
"00000000-0000-0000-0000-000000000000" (for example
"66864f3c-e095-d9c8-058d-d6575e6ed1b8").
There are 2^128 possible key combinations, yielding 340,282,366,920,938,463,463,374,607,431,768,211,456 possible keys. Abreviated as 3.40E+38 would normally be said as "3.4 times 10 to the 38th power". You could also call this 340
undecillion. Because of this, there is little worry over
SL running out of keys for objects, scripts, sounds, and textures.
Because a key is really just a specialized string, any string can be stored into a key
variable, though it shouldn't be expected to work in any function that needs a UUID if the key variable contains
"Hello". Note that keys must be
explicitly typecasted to strings, even though they are implicitly typecasted
from strings. If data needs to be
casted from any other type to a key, it must first be casted to a string.
That being said, if a UUID is not needed to be passed in a
llMessageLinked call, a second string can be passed as long as it is cast as a key and then recast back to a string in the receiving
link_message event.
Example:
This hack can be pretty useful, but keep in mind that you're relying on things that might change at any time when using it.
Note that in some cases, you don't need to explicitly state
(string)keyname as you do when converting between a string and an
integer, for instance. It's good coding practice to always do so, however, as many functions will not work properly unless you do.
string null_key = NULL_KEY;
integer isKey(key in)
{//Strife Onizuka
if(in) return 2;
return (in == null_key);
}//I win ^_^
key forceKey(key in)
{//force a string or key to be a valid key assuming you want invalids to become NULL_KEY
if(in) return in;
return null_key;
}
See
Client Asset Keys for default assets like
textures (
GUI, "missing",
terrain, etc),
animations,
sounds, etc.
Types |
Client Asset Keys