My name: Difference between revisions

From Kolmafia
Jump to navigation Jump to search
imported>Heeheehee
m Format-fixing.
imported>Zarqon
case is still important for some purposes; altered case of return value is worth knowing
Line 11: Line 11:
return_type={{#var:return_type}}|
return_type={{#var:return_type}}|
return_also={{#var:return_also}}}}|
return_also={{#var:return_also}}}}|
function_description=Returns the name of the logged-in character.|
function_description=Returns the name of the logged-in character (in all-lowercase).|
code1={{CodeSample|
code1={{CodeSample|
title=Code Samples|
title=Code Samples|
Line 25: Line 25:
</syntaxhighlight>}}
</syntaxhighlight>}}
{{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>
<syntaxhighlight>

Revision as of 13:30, 30 April 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.