my code works so far but the hero only builds one wall. any help will be greatly appreciated.
var hunter = hero.findNearest(hero.findFriends());
var fenceMap = hunter.getMap();
// This function converts grid into XY coordinates.
function convertCoor(row, col) {
return {x: 34 + col * 4, y: 26 + row * 4};
}
// Iterate over fenceMap and build at fence at all 1s.
for(var j = 0; j < fenceMap.length; j++) {
for(var i = 0; i<fenceMap.length; i++){
if(i && j == 1){
var coor = convertCoor(i,j);
hero.buildXY("fence", coor.x, coor.y);
}
}
}
// Move back to the village after building the fences.
hero.moveXY(22, 15);
@brooksy125 Could you guys please help me with this level. I still don’t understand after your explanation. My code is very similar to that of @Alexander_Hollowell. Thank you
# Our sleepwalking peasants are returning.
# But sleeping yetis are also coming.
# DONT WAKE UP THEM!.
# We need to build fences to pass peasants and stop yetis.
# Senick’s prepared the grid map how to build fences.
hunter = hero.findNearest(hero.findFriends())
fenceMap = hunter.getMap()
# This function convert grid map coordinates to x-y coordinates.
def convertCoor(row, col):
return {‘x’: 34 + col * 4, ‘y’: 26 + row * 4}
# Iterate fenceMap and if an element equals 1, then build there a fence.
for ri, row in enumerate(fenceMap):
for rx, col in enumerate(row):
if (col == 1):
coor = convertCoor(ri, rx)
hero.buildXY(‘fence’, coor.x, coor.y)
# Yetis wake up if they smell the hero near. Hide in the village.
hero.moveXY(22, 15)
Thank you for trying to help @jaden_the_best, but this topic has been dead for three months, if she still needed help she probably would have posted again.
I really appreciated you helping and please continue, but only on new topics. Otherwise no-one will see your post and your wasting your own time.
Danny