Differences

This shows you the differences between two versions of the page.

Link to this comparison view

wiki:scripting_portal:lsl_types:key [2018/11/18 23:42]
Royale Mobian created
wiki:scripting_portal:lsl_types:key [2018/11/19 15:40] (current)
Royale Mobian [Displaying avatar or group information]
Line 50: Line 50:
  
 ===== Displaying avatar or group information ===== ===== Displaying avatar or group information =====
 +If you know an avatar'​s key, you can display the avatar'​s name in the viewer window and chat history by using the following special URL:
 +<code ossl>
 +llOwnerSay("​secondlife:///​app/​agent/"​ + (string)owner_key + "/​about"​);​
 +</​code>​
 +This displays both display name and username as a clickable link that brings up an avatar profile window when clicked. It is easier than using llRequestAgentData or llRequestUsername or llRequestDisplayName,​ since there is no need to use a dataserver event.
 +
 +If you know a group key (as a result of calling llGetObjectDetails(key id, [OBJECT_GROUP]),​ or calling llGetParcelDetails(vector pos, [PARCEL_DETAILS_GROUP])),​ you can display the group'​s name with the following special URL:
 +<code ossl>
 +llOwnerSay("​secondlife:///​app/​group/"​ + (string)group_key + "/​about"​);​
 +</​code>​
 +This displays the group name as a clickable link that brings up a group profile window when clicked. This is especially useful since there is no other way to do this; there is no LSL function to print out a group'​s name.
 +
 +Finally, if you know a parcel key (as a result of calling llGetParcelDetails(vector pos, [PARCEL_DETAILS_ID])),​ you can create a clickable link that brings up a place profile window when clicked, using the following special URL:
 +<code ossl>
 +llOwnerSay("​secondlife:///​app/​parcel/"​ + (string)parcel_key + "/​about"​);​
 +</​code>​
 +
 +===== Testing for a valid key =====
 +
 +To test for a valid key, just do this:
 +<code ossl>
 +if(uuid){
 +     //do something
 +}
 +</​code>​
 +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"​
 +
 +Note! It is important for the above example that uuid be defined as a key. It can of course be typecast to be a key as well: if((key)uuid)
 +
 +Here is an example of how to build a function around this:
 +<code ossl>
 +// 2:         valid key, not NULL_KEY
 +// 1 (TRUE): ​ NULL_KEY
 +// 0 (FALSE): not a key
 + 
 +integer isKey(key in)
 +{
 +    if (in)
 +        return 2;
 +    return (in == NULL_KEY);
 +}
 +</​code>​
 +===== Caveats =====
 +<code ossl>
 +if (uuid)
 +</​code>​
 +is a special case. Keys cannot be converted to integers, so logical operators such as !, || and && cannot be used with keys. If you wish to do
 +<code ossl>
 +if (!uuid) { /* wont work */ }
 +</​code>​
 +then you can use a simple workaround like so:
 +<code ossl>
 +if (uuid) { } else { /* will work */ }
 +</​code>​
 +This is particularly useful if we wish to discard invalid string content (i.e - ensure that a key is actually a key) like so:
 +
 +if (uuid) ; else uuid = NULL_KEY;
 +
 +Be careful when adding key literals to lists, no implicit typecasting will take place. Failing to ensure that key literals are keys will cause problems with llListFindList. ​
QR Code
QR Code wiki:scripting_portal:lsl_types:key (generated for current page)