Difference between revisions of "My name"

From Kolmafia
Jump to navigation Jump to search
imported>Zarqon
(case is still important for some purposes; altered case of return value is worth knowing)
imported>Bale
m
 
Line 5: Line 5:
 
FunctionPage|
 
FunctionPage|
 
name={{#var:name}}|
 
name={{#var:name}}|
function_category=Your Character|
 
 
function1={{Function|
 
function1={{Function|
 
name={{#var:name}}|
 
name={{#var:name}}|
Line 42: Line 41:
 
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.