Is it "this. or "hero."?


#1

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){
        this.attack(enemy);
        this.devour(enemy);
        }  for (var i = 0; i < friends.length; ++i){
            var friend = friends[i];
            // Do something with each friend here
            this.follow(friends);
            }
        
}// end of while loop`Preformatted text`

#2

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


#3

Do hero.move(friend)


#4

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:


#5

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


#6

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