My name: Difference between revisions

From Kolmafia
Jump to navigation Jump to search
imported>Zarqon
Undo revision 4675 by Zarqon (Talk)
imported>Bale
mNo edit summary
 
(41 intermediate revisions by 6 users not shown)
Line 1: Line 1:
[[string]] [[my_name()]]
{{
#vardefine:name|my_name}}{{
#vardefine:return_type|string}}{{


This function returns the logged-in character's name as a [[string]] in all lowercase.
FunctionPage|
 
name={{#var:name}}|
[[Category:Your Character | My name()]]
function1={{Function|
[[Category:Ash Functions | My name()]]
name={{#var:name}}|
<pre>#Script checks players name. If your name returns ZammyWarrior it will import Zammy Morning.ash script.
aggregate={{#var:aggregate}}|
#If name returns Hippymon it will import Hippymon Morning.ash script.
return_type={{#var:return_type}}|
#Great script for one with multiple accounts as a "breakfast script".
return_also={{#var:return_also}}}}|
if (my_name() == "zammywarrior"){
function_description=Returns the name of the logged-in character (in all-lowercase).|
  import <Zammy Morning.ash>;
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
}
}
else if (my_name() == "hippymon"){
</syntaxhighlight>}}
  import <Hippy Morning.ash>;
{{CodeSample|
code=
<syntaxhighlight>
if (my_name() == "mycharacter") {
  //some_code_here
}
}
</pre>
</syntaxhighlight>}}|
 
see_also={{SeeAlso|my_id}}|
Note that even if your name is capitalized in KoL, my_name() will convert it to lowercase:
special=When not logged in, this function returns an empty string.
 
}}
<pre>if (my_name() == "My Capitalized Name") {
  // this block of commands will never be performed
}</pre>


When not logged in, this fuction 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.