[SOLVED] Steelclaw gap help (js)

var defendPoints = [{“x”: 35, “y”: 63},{“x”: 61, “y”: 63},{“x”: 32, “y”: 26},{“x”: 64, “y”: 26}];

var summonTypes = [“soldier”,“soldier”,“soldier”,“soldier”,“archer”,“archer”,“archer”,“archer”];

// You start with 360 gold to build a mixture of soldiers and archers.
// this.built is an array of the troops you have built, ever.
// Here we use “this.built.length % summonTypes.length” to wrap around the summonTypes array
function summonTroops() {
var type = summonTypes[hero.built.length % summonTypes.length];
if(hero.gold >= hero.costOf(type)) {
hero.summon(type);
}
}

function commandTroops() {
var friends = hero.findFriends();
for(var friendIndex=0; friendIndex < friends.length; friendIndex ++) {
var friend = friends[friendIndex];
// Use % to wrap around defendPoints based on friendIndex
defendPoint = defendPoints[friendIndex % defendPoints.length];
// Command your minion to defend the defendPoint
hero.command(friend, “defend”, defendPoint);
}
}

while(true) {
summonTroops();
commandTroops();
}

I dont know what I did wrong

Can you pls format it with 3 backticks.

2m
var defendPoints = [{“x”: 35, “y”: 63},{“x”: 61, “y”: 63},{“x”: 32, “y”: 26},{“x”: 64, “y”: 26}];

var summonTypes = [“soldier”,“soldier”,“soldier”,“soldier”,“archer”,“archer”,“archer”,“archer”];

// You start with 360 gold to build a mixture of soldiers and archers.
// this.built is an array of the troops you have built, ever.
// Here we use “this.built.length % summonTypes.length” to wrap around the summonTypes array
function summonTroops() {
var type = summonTypes[hero.built.length % summonTypes.length];
if(hero.gold >= hero.costOf(type)) {
hero.summon(type);
}
}

function commandTroops() {
var friends = hero.findFriends();
for(var friendIndex=0; friendIndex < friends.length; friendIndex ++) {
var friend = friends[friendIndex];
// Use % to wrap around defendPoints based on friendIndex
defendPoint = defendPoints[friendIndex % defendPoints.length];
// Command your minion to defend the defendPoint
hero.command(friend, “defend”, defendPoint);
}
}

while(true) {
summonTroops();
commandTroops();
}

var defendPoints = [{“x”: 35, “y”: 63},{“x”: 61, “y”: 63},{“x”: 32, “y”: 26},{“x”: 64, “y”: 26}];

var summonTypes = [“soldier”,“soldier”,“soldier”,“soldier”,“archer”,“archer”,“archer”,“archer”];

// You start with 360 gold to build a mixture of soldiers and archers.
// this.built is an array of the troops you have built, ever.
// Here we use “this.built.length % summonTypes.length” to wrap around the summonTypes array
function summonTroops() {
var type = summonTypes[hero.built.length % summonTypes.length];
if(hero.gold >= hero.costOf(type)) {
hero.summon(type);
}
}

function commandTroops() {
var friends = hero.findFriends();
for(var friendIndex=0; friendIndex < friends.length; friendIndex ++) {
var friend = friends[friendIndex];
// Use % to wrap around defendPoints based on friendIndex
defendPoint = defendPoints[friendIndex % defendPoints.length];
// Command your minion to defend the defendPoint
hero.command(friend, “defend”, defendPoint);
}
}

while(true) {
summonTroops();
commandTroops();
}

nevermind, i just finished the level

Haha that is so funny! :smile: Same thing happens to me. I post a topic asking for help and one minute later i figure out the answer :wink: