Is it "this. or "hero."?


Hi, i’m using naflar and i’m wondering in order to move my character I would normally type “this.moveXY” But however, i’m working on using “findFriends()” and so would I type “this.follow(friends)” or "hero.follow(friends)

// Remember that enemies may not yet exist.
while (true) {
    var enemy = hero.findNearestEnemy();
    var friends = hero.findFriends();
    // If there is an enemy, attack it!
    if (enemy){
        }  for (var i = 0; i < friends.length; ++i){
            var friend = friends[i];
            // Do something with each friend here
}// end of while loop`Preformatted text`


You can use either of them, because “this” and “hero” do the same things.


Do hero.move(friend)


this.method was the original notation, hero.method is the new and preferred notation. They are the same, but in some places you will still see (or get) the old one. Deal with it :sunglasses:


When I first started here, “self” was being used. When I was in Backwoods Forest everything changed to, hero. This, self, hero.


Officially, it’s hero – we still allow this and self to work because we didn’t want to break older code.