Talk:My name

From Kolmafia
Revision as of 23:57, 17 March 2010 by imported>Heeheehee (Response to Fronobulax's comments.)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

[1] mentions some possible issues with case sensitivity when using my_name as a string index to a map. That should be verified but, if true, the code examples might be better examples if they used lower case, i.e. if (my_name() == "fronobulax") instead of if (my_name == "Fronobulax") If both examples actually work then I would check the equality operator for case sensitivity, possibly update the wiki or file a Bug Report :-)


Looks like the == ignores case altogether, as shown by the following example: > ash print("heeheehee"=="HEEHEEHEE")

true

Also, this function does indeed return the player's username, converted to lowercase. Just confirmed that. I'd circumvent the whole map issue by just converting *everything* to lowercase, using the handy to_lower_case() function. =D Or, alternatively, although this uses more memory, loop over the elements in the map. So...

 foreach i in map {
    if(i==my_name()) {
       // Do stuff here.
       break;
    }
 }

--Heeheehee 23:57, 17 March 2010 (UTC)