Talk:My name: Difference between revisions

From Kolmafia
Jump to navigation Jump to search
imported>Fronobulax
Created page with '[http://kolmafia.us/showthread.php?3684-My-first-attempt-at-a-script&p=26025#post26025] mentions some possible issues with case sensitivity when using my_name as a string index t…'
 
imported>Heeheehee
m Response to Fronobulax's comments.
 
Line 1: Line 1:
[http://kolmafia.us/showthread.php?3684-My-first-attempt-at-a-script&p=26025#post26025] 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 :-)
[http://kolmafia.us/showthread.php?3684-My-first-attempt-at-a-script&p=26025#post26025] 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;
    }
  }
--[[User:Heeheehee|Heeheehee]] 23:57, 17 March 2010 (UTC)

Latest revision as of 23:57, 17 March 2010

[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)