Skip to content

Custom JS objects seem to confuse the transpiler #135

Description

@sotonin
var self, routine;

self = this;

routine = {
    enemies: false,
    targetNearby: function () {
        routine.enemies = self.findEnemies();
        for (var i = 0; i <= routine.enemies.length; ++i) {
            var enemy = routine.enemies[i];
            if (enemy) {
                var distance = self.distanceTo(enemy);
                if (distance <= 35) {
                    return true;
                } else {
                    return false;
                }
            } else {
                return false;
            }
        }
        return false;
    }
};

while (routine.targetNearby()) {
    self.say(routine.targetNearby());
}

This code seems to confuse it. routine.targetNearby() should return a simple true or false if there is a target nearby that satisfies the distance requirement. It's returning [Object Object] as per the heros say. My best guess is that it's actually returning the function object itself instead of executing the function. but thats just a guess.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions