Help with "cleave" command in level Siege of Stonehold


#1

Hey, I got a problem with the level “Siege of Stonehold”, I just can’t make the code " right", and I don’t know what I am supposed to change

 loop {
   var enemy = this.findEnemies();
   var green = this.findFlag("green");

if (green) {
    this.pickUpFlag(flag);
    this.moveXY(19, 69);
    } else {
        this.findNearest(enemy);
        if (this.isReady("cleave")) {
            this.cleave(enemy);
            } else {
                this.attack(enemy);
            }
    }
}

There is supposedly an error in Line 15 ( this.cleave(enemy) )… apparently I am told that “ArgumentError is not defined”… I rechecked everything ( that I know) could be wrong and tried since yesterday to make it work… I am really desperate as I really don’t even know, what’s wrong (as I just did everything as in the levels befor) :confused:


#2

On line 8, your command is this.findNearest(enemy);. This doesn’t work. You need to define it as a variable, like var nearest = this.findNearest(enemy).


#3

On line 8, your command is this.findNearest(enemy);. This doesn’t work. You need to define it as a variable, like:
“var nearest = this.findNearest(enemy)” Because in java script you ALWAYS make a variable first then you write a command.


#4

@ChronistGilver and @ameen
Thank you both so much for your help!!! Now I got through the level :blush:


#5

No problem if you have any problems just contact me


#6

One other potential problem with your code … what will happen if you drop a flag when there is no enemy? (Maybe not a real problem, but something to watch as a general style point.)