Unknown transpile error (stranded in the dunes JS)

code



function jumpTo(position, fast=true) {
    if (hero.isReady("jump")) {
        hero.jumpTo(position);
    }
    else {
        hero.move(position);
    }
}

function summon() {
    if (hero.costOf("soldier")) {
        hero.summon("soldier");
    }
}

function command(enemy) {
    var friends = hero.findFriends();
    for (var friend in friends) {
        if (enemy && friend.type === "soldier") {
            hero.command(friend, "attack", enemy);
        }
    }
}

function attack(enemy) {
    while(true) {
        
        if (enemy && enemy.type !== "sand-yak") {
            if (hero.isReady("power-up")) {
                
                hero.powerUp();
            }
            else if(hero.isReady("bash")) {
                hero.bash(enemy);
            }
            else if(hero.canCast("chain-lighting", enemy)) {
                hero.cast("chain-lighting", enemy);
            }
            else {
                hero.shield();
                hero.attack(enemy);
            }
        }
    }
}

jumpTo({'x':120, 'y':39});
while(true) {
    var item = hero.findNearestItem();
    var enemy = hero.findNearestEnemy();
    summon();
    if (item) {
        hero.move(item.pos);
    }
    else if(enemy) {
        command(enemy);
    }
    else if(enemy) {
        attack(enemy);
    }
    
}

try deleating the top imo

1 Like