Username Constant


  • Culture

    It would be super useful if out username was in a constant. While I know I could do this myself it isn't as good of an option for open source stuff.



  • Would also like to see this! 



  • your username is...

    Game.structures[function() { for (var s in Game.structures) return s }()].owner.username;


  • Culture

    It may be easy to get programmatically but making it a consistently available constant has benefits for open source libraries that will be shared amongst multiple people.



  • I agree, this should be added.

    In the meanwhile we will be stuck turning an object(hash), into an array, selecting the first element of that array, feeding it back into that same object to select the first object of the object(hash), and then selecting one property from that object. That's one of the more backwards lines of code I have had to come up with just to do a basic thing like know what your own username is.

    Game.spawns[Object.keys(Game.spawns)[0]].owner.username

     



  • This would be really handy!



  • Currently the easiest way to do this is something like global.WHOAMI = _.find(Game.structures).owner.username; as Game.structures will always contain at least one controller or spawn as long as you're alive. Note that's _.find and not _.first, which is limited to arrays.

    But I would love a Game.username or something.