What is wrong with my code? It`s Javascript and my hero is just standing still when I place the flag.
loop {
var flagG = this.findFlag("green");
var flagV = this.findFlag("violet");
var flagB = this.findFlag("black");
if (flagG) {
var posfG = flagG.pos;
var posxG = posfG.x;
var posyG = posfG.y;
this.buildXY("fence", posxG, posyG);
}
else if (flagV) {
var posfV = flagV.pos;
var posxV = posfV.x;
var posyV = posfV.y;
this.buildXY("fire-trap", posxV, posyV);
}
else if (flagB) {
var posfB = flagB.pos;
var posxB = posfB.x;
var posyB = posfB.y;
this.moveXY(posxB, posyB);
}
}
I had a go at this command, but my hero is still standing like he`s never gonna move and the message āUnreachable while after returnā keeps on appearingā¦
loop {
var flagG = this.findFlag(āgreenā);
var flagV = this.findFlag(āvioletā);
var flagB = this.findFlag(āblackā);
if (flagG) {
var posfG = flagG.pos;
var posxG = posfG.x;
var posyG = posfG.y;
this.buildXY(āfenceā, posxG, posyG);
this.pickUpFlag(āgreenā);
}
else if (flagV) {
var posfV = flagV.pos;
var posxV = posfV.x;
var posyV = posfV.y;
this.buildXY(āfire-trapā, posxV, posyV);
this.pickUpFlag(violet);
}
else if (flagB) {
var posfB = flagB.pos;
var posxB = posfB.x;
var posyB = posfB.y;
this.moveXY(posxB, posyB);
this.pickUpFlag(black);
}
}
that the problem , you started the loop with a green variable wich is not existed yet , make a variables called it as flag = find flag then use your codes insdie another if flag statment , hit submit a post a flag somewhere , hope itās help you
@shoodong Please donāt post so many unrelated messages in a thread in a row. If you have more ideas, you can edit your one existing post in a thread. Try also to not resurrect old threads that no one is paying attention to any more, especially if there are newer threads on the same topic.