Difference between revisions of "My name"

From Kolmafia
Jump to navigation Jump to search
imported>StDoodle
m
imported>Bale
m
 
(30 intermediate revisions by 4 users not shown)
Line 1: Line 1:
{{DISPLAYTITLE:my_name()}}
+
{{
{{function|
+
#vardefine:name|my_name}}{{
name=my_name|
+
#vardefine:return_type|string}}{{
returns=string|
+
 
 +
FunctionPage|
 +
name={{#var:name}}|
 +
function1={{Function|
 +
name={{#var:name}}|
 +
aggregate={{#var:aggregate}}|
 +
return_type={{#var:return_type}}|
 +
return_also={{#var:return_also}}}}|
 +
function_description=Returns the name of the logged-in character (in all-lowercase).|
 +
code1={{CodeSample|
 +
title=Code Samples|
 +
description=This example imports different breakfast scripts depending on which character is running the script.|
 +
code=
 +
<syntaxhighlight>
 +
if (my_name() == "MyMain") {
 +
  import <MainBreakfast.ash>;
 +
}
 +
else if (my_name() == "MyMulti") {
 +
  import <MultiBreakfast.ash>;
 +
}
 +
</syntaxhighlight>}}
 +
{{CodeSample|
 +
description=Note that case doesn't matter for string comparisons, so the following two examples are functionally equivalent.|
 +
code=
 +
<syntaxhighlight>
 +
if (my_name() == "MyCharacter") {
 +
  //some_code_here
 +
}
 +
</syntaxhighlight>}}
 +
{{CodeSample|
 +
code=
 +
<syntaxhighlight>
 +
if (my_name() == "mycharacter") {
 +
  //some_code_here
 +
}
 +
</syntaxhighlight>}}|
 +
see_also={{SeeAlso|my_id}}|
 +
special=When not logged in, this function returns an empty string.
 
}}
 
}}
This function returns the logged-in character's name as a [[string]].
 
 
This example imports different breakfast scripts depending on which character is running the script.
 
<code>
 
  if ([[my_name()]] == "zammywarrior") {
 
    [[import]] <Zammy Morning.ash>;
 
  }
 
  else if ([[my_name()]] == "hippymon") {
 
    [[import]] <Hippy Morning.ash>;
 
  }
 
</code>
 
 
Note that capitalization is not strictly adhered to. When using [[my_name()]] the following examples are functionally equivalent:
 
 
<code>
 
  if ([[my_name()]] == "That FN Ninja") {
 
    [[comments| // code]]
 
  }
 
</code>
 
 
<code>
 
  if ([[my_name()]] == "that fn ninja") {
 
    [[comments|// code]]
 
  }
 
</code>
 
[[Category:Your Character | My name()]]
 
[[Category:Ash Functions | My name()]]
 
  
When not logged in, this function returns an empty string.
+
[[Category:Your Character]]

Latest revision as of 21:31, 21 May 2010

Function Syntax

string my_name()

Returns the name of the logged-in character (in all-lowercase).

Code Samples

This example imports different breakfast scripts depending on which character is running the script.

if (my_name() == "MyMain") {
  import <MainBreakfast.ash>;
}
else if (my_name() == "MyMulti") {
  import <MultiBreakfast.ash>;
}

Note that case doesn't matter for string comparisons, so the following two examples are functionally equivalent.

if (my_name() == "MyCharacter") {
  //some_code_here
}


if (my_name() == "mycharacter") {
  //some_code_here
}

See Also

my_id()

Special

When not logged in, this function returns an empty string.