Difference between revisions of "My name"

From Kolmafia
Jump to navigation Jump to search
imported>Zarqon
m (still more links)
imported>That FN Ninja
m (my_name() is not case sensative.)
Line 1: Line 1:
 
[[string]] [[my_name()]]
 
[[string]] [[my_name()]]
  
This function returns the logged-in character's name as a [[string]] in all lowercase.
+
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.
 
This example imports different breakfast scripts depending on which character is running the script.
Line 13: Line 13:
 
</code>
 
</code>
  
Note that even if your name is capitalized in KoL, [[my_name()]] will convert it to lowercase:
+
Note that capitalization is not strictly adhered to. When using [[my_name()]] the following examples are functionally equivalent:
  
 
<code>
 
<code>
   if ([[my_name()]] == "My Capitalized Name") {
+
   if ([[my_name()]] == "That FN Ninja") {
    [[comments|// this block of commands will never be performed]]
+
    [[comments| // code]]
 +
  }
 +
</code>
 +
 
 +
<code>
 +
  if ([[my_name()]] == "that fn ninja") {
 +
    [[comments|// code]]
 
   }
 
   }
 
</code>
 
</code>
Line 23: Line 29:
 
[[Category:Ash Functions | My name()]]
 
[[Category:Ash Functions | My name()]]
  
When not logged in, this fuction returns an empty string.
+
When not logged in, this function returns an empty string.

Revision as of 04:42, 23 December 2009

string my_name()

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.

 if (my_name() == "zammywarrior") {
   import <Zammy Morning.ash>;
 }
 else if (my_name() == "hippymon") {
   import <Hippy Morning.ash>;
 }

Note that capitalization is not strictly adhered to. When using my_name() the following examples are functionally equivalent:

 if (my_name() == "That FN Ninja") {
     // code
 }

 if (my_name() == "that fn ninja") {
    // code
 }

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