Difference between revisions of "My name"

From Kolmafia
Jump to navigation Jump to search
imported>StDoodle
m
imported>Bale
m
 
(14 intermediate revisions by 3 users not shown)
Line 1: Line 1:
{{FunctionPage |
+
{{
page_name=my_name|
+
#vardefine:name|my_name}}{{
function_category=Your Character |
+
#vardefine:return_type|string}}{{
function1_return_type=string|
+
 
function_description=Returns the name of the logged-in character, all in lowercase.|
+
FunctionPage|
code1={{CodeSample |
+
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|
 
title=Code Samples|
 
description=This example imports different breakfast scripts depending on which character is running the script.|
 
description=This example imports different breakfast scripts depending on which character is running the script.|
 
code=
 
code=
<syntaxhighlight lang="c">
+
<syntaxhighlight>
 
if (my_name() == "MyMain") {
 
if (my_name() == "MyMain") {
 
   import <MainBreakfast.ash>;
 
   import <MainBreakfast.ash>;
Line 15: Line 22:
 
   import <MultiBreakfast.ash>;
 
   import <MultiBreakfast.ash>;
 
}
 
}
</syntaxhighlight>}} |
+
</syntaxhighlight>}}
code2={{CodeSample |
+
{{CodeSample|
description=Note that capitalization is not strictly adhered to (much as with the chat command "/whois" in game). The following two examples are functionally equivalent.|
+
description=Note that case doesn't matter for string comparisons, so the following two examples are functionally equivalent.|
 
code=
 
code=
<syntaxhighlight lang="c">
+
<syntaxhighlight>
 
if (my_name() == "MyCharacter") {
 
if (my_name() == "MyCharacter") {
   //code
+
   //some_code_here
 
}
 
}
</syntaxhighlight>}} |
+
</syntaxhighlight>}}
code3={{CodeSample |
+
{{CodeSample|
 
code=
 
code=
<syntaxhighlight lang="c">
+
<syntaxhighlight>
 
if (my_name() == "mycharacter") {
 
if (my_name() == "mycharacter") {
   //code
+
   //some_code_here
 
}
 
}
</syntaxhighlight>}} |
+
</syntaxhighlight>}}|
see_also={{SeeAlso|my_id}}
+
see_also={{SeeAlso|my_id}}|
 
special=When not logged in, this function returns an empty string.
 
special=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.