My name: Difference between revisions

From Kolmafia
Jump to navigation Jump to search
imported>StDoodle
m moved My name() to My name
imported>StDoodle
No edit summary
Line 1: Line 1:
 
{{FunctionPage |
{{function |
page_name=my_name|
name=my_name|
function1_return_type=string|
returns=string|
function_description=Returns the name of the logged-in character.|
code1={{CodeSample |
title=Code Samples|
description=This example imports different breakfast scripts depending on which character is running the script.|
code=
<syntaxhighlight lang="c">
if (my_name() == "MyMain") {
  import <MainBreakfast.ash>;
}
else if (my_name() == "MyMulti") {
  import <MultiBreakfast.ash>;
}
</syntaxhighlight>}} |
code2={{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.|
code=
<syntaxhighlight lang="c">
if ([[my_name()]] == "MyCharacter") {
  //code
}
</syntaxhighlight>}} |
code3={{CodeSample |
code=
<syntaxhighlight lang="c">
if ([[my_name()]] == "MyCharacter") {
  //code
}
</syntaxhighlight>}} |
special=When not logged in, this function returns an empty string.
}}
}}
 
[[Category:Your Character]]
This function returns the logged-in character's name as a [[string]].
 
This example imports different breakfast scripts depending on which character is running the script.
<code>
  if ([[my_name()]] == "zammywarrior") {
    [[import]] <Zammy Morning.ash>;
  }
  else if ([[my_name()]] == "hippymon") {
    [[import]] <Hippy Morning.ash>;
  }
</code>
 
Note that capitalization is not strictly adhered to. When using [[my_name()]] the following examples are functionally equivalent:
 
<code>
  if ([[my_name()]] == "That FN Ninja") {
    [[comments| // code]]
  }
</code>
 
<code>
  if ([[my_name()]] == "that fn ninja") {
    [[comments|// code]]
  }
</code>
[[Category:Your Character | My name()]]
[[Category:Ash Functions | My name()]]
 
When not logged in, this function returns an empty string.

Revision as of 12:16, 25 February 2010

Function Syntax

Returns the name of the logged-in character.

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") {
  //code
}
if ([[my_name()]] == "MyCharacter") {
  //code
}

Special

When not logged in, this function returns an empty string.