Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Custom JS objects seem to confuse the transpiler #135

Open
sotonin opened this issue Jan 22, 2015 · 1 comment
Open

Custom JS objects seem to confuse the transpiler #135

sotonin opened this issue Jan 22, 2015 · 1 comment
Labels

Comments

@sotonin
Copy link

sotonin commented Jan 22, 2015

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.

@nwinter nwinter added the bug label Jan 22, 2015
@nwinter
Copy link
Contributor

nwinter commented May 22, 2016

With the interpreter, this kind of code now gives a new error:

screenshot 2016-05-22 08 28 33

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants