Difference between revisions of "Category:LSL Avatar/Name"

From Second Life Wiki
Jump to navigation Jump to search
m
m
 
(22 intermediate revisions by 9 users not shown)
Line 1: Line 1:
{{LSL Header}}{{LSLC|}}{{LSLC|Avatar}}[[Category:Display Names]]
{{LSL Header|ml=*}}{{LSLC|}}{{LSLC|Avatar}}[[Category:Display Names]]
{{RightToc}}
===Names===
===Names===
From an LSL standpoint avatars can have 3 different names.
From an LSL standpoint avatars can have 3 different names.


{| {{Prettytable}}
{| {{Prettytable}}
! Names:
! Naming
! {{Hl2}} | Description
! {{Hl2}} | Description
! {{Hl2}} | Unique
! {{Hl2}} | Get (in region)
! {{Hl2}} | Get (in region)
! {{Hl2}} | Request ([[dataserver]])
! {{Hl2}} | Request ([[dataserver]])
Line 11: Line 13:
! {{Hl2}} | {{LSLGC|Detected|detected}} events
! {{Hl2}} | {{LSLGC|Detected|detected}} events
|-
|-
! {{Hl2}} | Display
! {{Hl2}} | {{LSLGC|Display Name}}
| The name that is displayed on the screen.
| The name that is displayed on the screen.
| No
| [[llGetDisplayName]]
| [[llGetDisplayName]]
| [[llRequestDisplayName]]
| [[llRequestDisplayName]]
| NA
| [[Display Names/LSL#What about an AGENT_BY_DISPLAY_NAME flag for llSensor?|N/A]]
| {{HoverText|NA|Use llGetDisplayName in conjunction with llDetectedKey.}}
| {{HoverText|N/A|Use llGetDisplayName in conjunction with llDetectedKey.}}
|-
|-
! {{Hl2}} | User
! {{Hl2}} | {{LSLGC|Username}}
| The name the users logs in with.
| The name the users logs in with.
| Yes
| [[llGetUsername]]
| [[llGetUsername]]
| [[llRequestUsername]]
| [[llRequestUsername]]
| [[AGENT_BY_USERNAME]]
| [[AGENT_BY_USERNAME]]
| {{HoverText|NA|Use llGetUsername in conjunction with llDetectedKey.}}
| {{HoverText|N/A|Use llGetUsername in conjunction with llDetectedKey.}}
|-
|-
! {{Hl2}} | Legacy
! {{Hl2}} | {{LSLGC|Legacy Name}}
| An interface predating [[Display Names]].
| An interface predating [[Display Names]].
| Yes
| [[llKey2Name]]
| [[llKey2Name]]
| [[llRequestAgentData]]
| [[llRequestAgentData]]
Line 32: Line 37:
| [[llDetectedName]]
| [[llDetectedName]]
|}
|}
{| {{prettytable|style=float:right;margin-top:0;}}
{| {{Prettytable|style=float: right; margin-top: 0;}}
|+ <h4>Name Formats by Account Type</h4>
|+ Name Formats by Account Type
|
! Naming
! {{Hl2}} | Modern
! {{Hl2}} | Modern
! {{Hl2}} | Legacy
! {{Hl2}} | Legacy
|-
|-
! {{Hl2}} | User Name
! {{Hl2}} | Default {{LSLGC|Display Name}}
| "username"
| "FirstName"
| "FirstName LastName"
|-
! {{Hl2}} | {{LSLGC|Username}}
| "firstname"
| "firstname.lastname"
| "firstname.lastname"
|-
|-
! {{Hl2}} | Legacy Name
! {{Hl2}} | {{LSLGC|Legacy Name}}
| "username Resident"
| "FirstName Resident"
| "FirstName LastName"
|-
! {{Hl2}} | Display Default
| "username"
| "FirstName LastName"
| "FirstName LastName"
|}
|}
=== Modern and Legacy Accounts ===
=== Modern and Legacy Accounts ===
* Modern accounts are created by choosing a user name, which consists of one name (no spaces).
* Modern accounts are created by choosing a user name, which consists of one name (no spaces).
Line 56: Line 62:
To maintain compatibility with legacy scripts (that expect two names), modern accounts are given the legacy last name "Resident".
To maintain compatibility with legacy scripts (that expect two names), modern accounts are given the legacy last name "Resident".


The default value of the Display Name depends upon the type of the account. For legacy accounts, it's the Legacy Name, for modern accounts, its the Username.
==== Default Display Name ====
 
The default value of the Display Name depends upon the type of the account. For modern accounts, it is the first part of the Legacy Name (without the space and last name "Resident"; this is the same as the Username with capitalization used at registration time preserved). For legacy accounts, it is the full Legacy Name.
<source lang="lsl2">
string agentDefaultName(string agentUsername, string agentLegacyName) {
    integer i = llStringLength(agentUsername);
    if (i < llStringLength(agentLegacyName)) {
        // modern account
        return llDeleteSubString(agentLegacyName, i, -1);
    } else {
        // legacy account
        return agentLegacyName;
    }
}
</source>
 
==== Legacy Name to Username ====
 
The relationship between the Username and Legacy Name is simple. The Username for a specific Legacy Name is the Legacy Name in lowercase with the space replaced with a period. If the last name of the Legacy Name is "Resident", then the username is just the Legacy Name first name in lowercase (without the last name or the period).
 
<source lang="lsl2">
string agentUsername(string agentLegacyName) {
    return llDumpList2String(llParseString2List(llToLower(agentLegacyName)+" ", [" resident ", " "],[]), ".");
}</source>
 
''If a Username is passed into this function instead of a Legacy Name, the Username will still be returned.''
 
=== Changed names ===
 
If your script has stored an avatar name and someone claims to be that avatar but they have changed their name, it is possible to combine two functions to find out if that is true.
 
{{KBtip|custom=Avoid this problem|<br/>Don't store avatars by name because names can change; to remember an avatar, store the key}}
 
Get the key for the name they claim to have used in the past using [[llRequestUserKey]]. You can compare that to any key for them you already have, or you can convert that key to its current name using [[llRequestUsername]]. An example script that does this is [[NameTest]].
 
*''Please'' don't use LSL to provide these translations from outside Second Life using http requests; we have an [[Name to agent ID API|externally accessible API]] that provides the same capability and does not contribute to simulator lag.
 
=== Other names ===
 
====Complete Name====
[[Viewer URI Name Space]] apparently also defines something called a Complete Name, which seems to be just the Display Name made unique by appending the Username in parenthesis when the Display Name is not set to its default value (and just the Display Name when it is set to its default value).
<source lang="lsl2">
string agentCompleteName(string agentDisplayName, string agentUsername, string agentLegacyName) {
    if (agentDisplayName == agentDefaultName(agentUsername, agentLegacyName)) {
        return agentDisplayName;
    } else {
        return agentDisplayName + " (" + agentUsername + ")";
    }
}
</source>


<lsl>string LegacyToUserName(string legacy)
====Web Name====
{
Some Second Life web pages (e.g., friends online: https://secondlife.com/my/account/friends.php or search results from: http://search.secondlife.com/) seem to return another form of naming similar to the Complete Name. This name is also just the Display Name made unique by appending a unique name in parenthesis when the Display Name is not set to its default value. The difference seems to be that the appended unique value is the default Display Name, instead of the Username, so this name always contains the default Display Name (with the current Display Name prepended).
     list name = llParseString2List(legacy, [" "]);
<source lang="lsl2">
     if(llList2String(name, 1) == "Resident")//it's not a legacy account.
string agentWebName(string agentDisplayName, string agentUsername, string agentLegacyName) {
         return llList2String(name, 0);//first name is username
     string agentDefaultName = agentDefaultName(agentUsername, agentLegacyName);
     return llToLower(llDumpList2String(name, "."));
     if (agentDisplayName == agentDefaultName) {
}</lsl>
         return agentDisplayName;
     } else {
        return agentDisplayName + " (" + agentDefaultName + ")";
    }
}
</source>


=== Legacy-Name Only Functions ===
=== Legacy-Name Only Functions ===
Line 71: Line 131:


* [[llCollisionFilter]]
* [[llCollisionFilter]]
* [[llListen]]
* [[llListen]] - likewise the [[listen]] {{LSLGC|Events|event}} only has a Legacy Name parameter.


===FAQs===
===FAQs===
There are a couple of FAQs that go into much more detail about this:
There are a couple of FAQs that go into much more detail about this:
* LSL FAQ: [[Display_Names/LSL]]
* LSL FAQ: [[Display Names/LSL]]
* General FAQ: [[Display_Names]]
* General FAQ: [[Display Names]]

Latest revision as of 09:58, 28 September 2020

Names

From an LSL standpoint avatars can have 3 different names.

Naming Description Unique Get (in region) Request (dataserver) llSensor(Repeat) flags detected events
Display Name The name that is displayed on the screen. No llGetDisplayName llRequestDisplayName N/A N/A
Username The name the users logs in with. Yes llGetUsername llRequestUsername AGENT_BY_USERNAME N/A
Legacy Name An interface predating Display Names. Yes llKey2Name llRequestAgentData AGENT_BY_LEGACY_NAME llDetectedName
Name Formats by Account Type
Naming Modern Legacy
Default Display Name "FirstName" "FirstName LastName"
Username "firstname" "firstname.lastname"
Legacy Name "FirstName Resident" "FirstName LastName"

Modern and Legacy Accounts

  • Modern accounts are created by choosing a user name, which consists of one name (no spaces).
  • Legacy accounts were created by choosing two names: first and last names. These two names are used together to form the username.

To maintain compatibility with legacy scripts (that expect two names), modern accounts are given the legacy last name "Resident".

Default Display Name

The default value of the Display Name depends upon the type of the account. For modern accounts, it is the first part of the Legacy Name (without the space and last name "Resident"; this is the same as the Username with capitalization used at registration time preserved). For legacy accounts, it is the full Legacy Name.

string agentDefaultName(string agentUsername, string agentLegacyName) {
    integer i = llStringLength(agentUsername);
    if (i < llStringLength(agentLegacyName)) {
        // modern account
        return llDeleteSubString(agentLegacyName, i, -1);
    } else {
        // legacy account
        return agentLegacyName;
    }
}

Legacy Name to Username

The relationship between the Username and Legacy Name is simple. The Username for a specific Legacy Name is the Legacy Name in lowercase with the space replaced with a period. If the last name of the Legacy Name is "Resident", then the username is just the Legacy Name first name in lowercase (without the last name or the period).

string agentUsername(string agentLegacyName) {
    return llDumpList2String(llParseString2List(llToLower(agentLegacyName)+" ", [" resident ", " "],[]), ".");
}

If a Username is passed into this function instead of a Legacy Name, the Username will still be returned.

Changed names

If your script has stored an avatar name and someone claims to be that avatar but they have changed their name, it is possible to combine two functions to find out if that is true.

KBtip2.png Avoid this problem
Don't store avatars by name because names can change; to remember an avatar, store the key

Get the key for the name they claim to have used in the past using llRequestUserKey. You can compare that to any key for them you already have, or you can convert that key to its current name using llRequestUsername. An example script that does this is NameTest.

  • Please don't use LSL to provide these translations from outside Second Life using http requests; we have an externally accessible API that provides the same capability and does not contribute to simulator lag.

Other names

Complete Name

Viewer URI Name Space apparently also defines something called a Complete Name, which seems to be just the Display Name made unique by appending the Username in parenthesis when the Display Name is not set to its default value (and just the Display Name when it is set to its default value).

string agentCompleteName(string agentDisplayName, string agentUsername, string agentLegacyName) {
    if (agentDisplayName == agentDefaultName(agentUsername, agentLegacyName)) {
        return agentDisplayName;
    } else {
        return agentDisplayName + " (" + agentUsername + ")";
    }
}

Web Name

Some Second Life web pages (e.g., friends online: https://secondlife.com/my/account/friends.php or search results from: http://search.secondlife.com/) seem to return another form of naming similar to the Complete Name. This name is also just the Display Name made unique by appending a unique name in parenthesis when the Display Name is not set to its default value. The difference seems to be that the appended unique value is the default Display Name, instead of the Username, so this name always contains the default Display Name (with the current Display Name prepended).

string agentWebName(string agentDisplayName, string agentUsername, string agentLegacyName) {
    string agentDefaultName = agentDefaultName(agentUsername, agentLegacyName);
    if (agentDisplayName == agentDefaultName) {
        return agentDisplayName;
    } else {
        return agentDisplayName + " (" + agentDefaultName + ")";
    }
}

Legacy-Name Only Functions

These functions only take Legacy Names and there are no alternative functions available.

FAQs

There are a couple of FAQs that go into much more detail about this:

Subcategories

This category has the following 5 subcategories, out of 5 total.

Pages in category "LSL Avatar/Name"

The following 9 pages are in this category, out of 9 total.