Difference between revisions of "My name"

From Kolmafia
Jump to navigation Jump to search
imported>StDoodle
m
imported>StDoodle
m
Line 29: Line 29:
 
<syntaxhighlight>
 
<syntaxhighlight>
 
if (my_name() == "MyCharacter") {
 
if (my_name() == "MyCharacter") {
   //code
+
   //some_code_here
 
}
 
}
 
</syntaxhighlight>}}|
 
</syntaxhighlight>}}|
Line 36: Line 36:
 
<syntaxhighlight>
 
<syntaxhighlight>
 
if (my_name() == "mycharacter") {
 
if (my_name() == "mycharacter") {
   //code
+
   //some_code_here
 
}
 
}
 
</syntaxhighlight>}}|
 
</syntaxhighlight>}}|

Revision as of 02:10, 12 March 2010

Function Syntax

string my_name()

Returns the name of the logged-in character, all in 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 capitalization is not strictly adhered to (much as with the chat command "/whois" in game). 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.