Keeping Time Code Help

Hi! When I submit this code, it says “unmatched parenthesis”. I need help organizing this code. Can anyone plz help me out? Thx!

Yariel

// Use your new skill to choose what to do: this.now()
loop {
// If it's the first 10 seconds, fight.
if (this.now() < 10) {
var enemy = this.findNearest(this.findEnemies());
if (enemy) {
if (this.distanceTo(enemy) < 10 && this.isReady('cleave')) {
this.cleave(enemy);
} else {
this.attack(enemy);
}
}
}

// Else, if it's the first 30 seconds, collect coins.
if ((this.now() >= 10) && (this.now() <= 30)) {
    var item = this.findNearest(this.findItems());
    this.move(item.pos);
}
// After 30 seconds, join the raid!
if (this.now() > 30) {
    var greenflag = this.findFlag();
    if (greenflag) { this.pickUpFlag(greenflag);}
    enemy = this.findNearest(this.findEnemies());
    if (enemy) {
        if (this.distanceTo(enemy) < 10) {
    if (this.isReady("cleave")) {
            this.cleave(enemy);
        } else {
            this.attack(enemy);
        }
    }
}
}
}

Your code is extremely hard to read due to wrong indentations. Please indent your code properly as this helps you to prevent “unmatched parentheses”-bugs and in general a lot of headache.


Despite the messy indentations, your code is syntactically perfectly valid. I checked by eye and with a syntax-checker. All opened whatevers are closed and vice versa. Your parentheses, quotation marks, semicolons, everything looks (syntactically) right.

Are you sure you posted the whole code? Maybe there is another bracket at the end you missed and that was never opened?

Yeah. I did. I’ll re-post my code and print my screen.

// Use your new skill to choose what to do: this.now()
loop {
// If it's the first 10 seconds, fight.
if (this.now() < 10) {
var enemy = this.findNearest(this.findEnemies());
if (enemy) {
if (this.distanceTo(enemy) < 10 && this.isReady('cleave')) {
this.cleave(enemy);
} else {
this.attack(enemy);
}
}
}

// Else, if it's the first 30 seconds, collect coins.
if ((this.now() >= 10) && (this.now() <= 30)) {
    var item = this.findNearest(this.findItems());
    this.move(item.pos);
}
// After 30 seconds, join the raid!
if (this.now() > 30) {
    var greenflag = this.findFlag();
    if (greenflag) { this.pickUpFlag(greenflag);}
    enemy = this.findNearest(this.findEnemies());
    if (enemy) {
        if (this.distanceTo(enemy) < 10) {
    if (this.isReady("cleave")) {
            this.cleave(enemy);
        } else {
            this.attack(enemy);
        }
    }
}
}
}
```<img src="//cdck-file-uploads-global.s3.dualstack.us-west-2.amazonaws.com/business6/uploads/codecombat/original/2X/f/f053ac3d8347419b29868a5bf137a33c1a4e46f1.png" width="690" height="388"><img src="//cdck-file-uploads-global.s3.dualstack.us-west-2.amazonaws.com/business6/uploads/codecombat/original/2X/e/eec2d081b1cc386359bfc7755601208ce4bdbb29.png" width="690" height="388"><img src="//cdck-file-uploads-global.s3.dualstack.us-west-2.amazonaws.com/business6/uploads/codecombat/original/2X/f/f46798a4addda9c80c27a9595b93fc5b5ae13598.png" width="690" height="388"><img src="//cdck-file-uploads-global.s3.dualstack.us-west-2.amazonaws.com/business6/uploads/codecombat/original/2X/3/3557b44389313503e43640a8aa00b4ae9da66c8e.png" width="690" height="388">

You don’t have glasses to findItems(); you’ll need to use the findNearestItem() method to get the nearest coin. (Or if you already own said glasses equip that instead.)

Ohhh… Ok. But y does it say:" Line 17: tmp47[tmp48] is not a fuction." What’s wrong w/that???

I finally did it! Thx a lot guys!!!

For clarification:
Line 17 raises an error because the function (or method) .findItems() doesn’t exist without the glasses.