Siege of stonehold [HELP]

Hello I am a but confused with this level. My character will not respond to any code I put in front of him.
As you can see in this screenshot I tried using flags to get him to respond but it still wont work…


I have even tried stuff as simple as hero.move(x, y);

1 Like

it should be

loop {

2 Likes

You must first assign hero.findFlag to a variable. Perhaps write something like:

var flag = [insert findflag function]
if(hero.findFlag){
   [insert moveXY to flog]
   hero.pickUpflag( [insert variable's name]);
}

As for the rest of the level, it will take much more than moving to flags.

1 Like

You must also do

loop {
    var flag = hero.find flag()
    if flag {
            hero.pickUpFlag(flag)
1 Like

You should also attack enemies

2 Likes

@CHECHA1232 *findFlag, not find flag.

1 Like

Oops, My computer messed up

1 Like

I am not great at javascript. Im more of a python coder:slight_smile:

1 Like

Still will not work. @_TD_RodYT @CHECHA1232

1 Like

I am only seeing why my character will not move. I am not trying to complete the whole level at the moment.

1 Like

Nooo. Listen carefully.

hero.findFlag is a FUNCTION. It means nothing.

You should use if (flag) instead because flag has already been assigned to a value when you called the findFlag function.

2 Likes

You also must indent correctly

2 Likes

OH stupid me, Thanks.

1 Like

Indent proper areas.

2 Likes

I’m having a similar issue. I assigned a variable for flags:

flag = hero.findFlag()

Then used a loop for moving and picking it up:

while True:
    if flag:
        hero.moveXY(flag.pos.x, flag.pos.y)
        hero.pickUpFlag(flag)

But for some reason my hero will not move to the flag. Any thoughts?

1 Like

You can just pickUpFlag(flag) instead of having to move to it. Using this method, your hero automatically moves to it and picks it up. No move statement required :wink:
Also define flag in the loop.

Need help with Siege of Stonehold
Here is my code:

var flagG = hero.findFlag("green");
var flagB = hero.findFlag("black");
var flag = hero.findFlag("green" || "black);
function pickUp(flag) {
    var item = hero.findNearestItem();
    var position = item.pos;
    var x = position.x;
    var y = position.y;
    var flagV = hero.findFlag(flagG);
    var flagB = hero.findFlag(FalgB);
    if (flagG) {
        hero.moveXY(x, y);
        hero.pickUpFlag(flagG);
    }
    if (flagB) {
        hero.moveXY(x, y);
        hero.pickUpFlag(flagB);
    }
}
var enemy = hero.findNearestEnemy();
while (true) {
    pickUp(flag);
    if (flagG)
        pickUp(flag);
    if (enemy) {
        hero.attack(enemy);
    }
    if (flagB) {
        pickUp(flag);
        var ready = hero.isReady("cleave");
        if (enemy) {
            if (ready) {
                hero.cleave(enemy);
            }
        }
    }
}

[en_US.composer.my_buttons_text]