Alright bear with me because this is EXTREMELY long on me trying to figure stuff out but in conclusion I came up with a few questions!
/*
while(true) {
var friend = hero.findNearest(hero.findFriends());
hero.moveXY(friend.pos.x, friend.pos.y -6);
}
*/
/*while (true) {
var names = ["Tharin", "Hattori"];
hero.moveXY(names[0].pos.x, names[1].pos.y);
}*/
/*while (true) {
var friends = hero.findFriends();
var xi = null;
var yi = null;
var i = 0;
var friend = friends[i];
if (friend && friend.pos.x == hero.pos.x) {
xi = friend.pos.x;
}
if (friend && friend.pos.y == hero.pos.y) {
yi = friend.pos.y;
}
hero.moveXY(xi, yi);
}
*/
/*var friends = hero.findFriends();
var i = 0;
var friend = friends[i];
while (i < friends.length){
friend = friends[i];
hero.say(friend);
i++;
}
*/
/* [0]"Amara", [1]"Senick", [2]"Pender", [3]"Kleene", [4]"Tharin", [5]"Omarn", [6]"Hattori", [7]"Anya", [8]"Hushbaum", [9]"Naria" (possibly try moving in sync with these)
*/
/*
var friends = hero.findFriends();
var i = 0;
var friend = friends[i];
function iy() {
while (i < friends.length) {
friend = friends[i];
if (friend.pos.x == hero.pos.x) {
return friend.pos.x;
} else {
i++;
}
}
}
i = 0;
function ix() {
while (i < friends.length) {
friend = friends[i];
if (friend.pos.y == hero.pos.y) {
return friend.pos.y;
} else {
i++;
}
}
}
while (true){
var fx = ix();
var fy = iy();
hero.moveXY(fx, fy);
}
*/
/* [0]"Amara", [1]"Senick", [2]"Pender", [3]"Kleene", [4]"Tharin", [5]"Omarn", [6]"Hattori", [7]"Anya", [8]"Hushbaum", [9]"Naria" (possibly try moving in sync with these)
*/
/*
while (true) {
var friends = hero.findFriends();
var i = 0;
hero.moveXY(friends[4].pos.x, friends[6].pos.y);
}
*/
/*
var friend = hero.findNearest(hero.findFriends());
var offsetX = friend.pos.x - hero.pos.x;
var offsetY = friend.pos.y - hero.pos.y;
while(true) {
hero.move({'x': friend.pos.x - offsetX, 'y': friend.pos.y - offsetY});
}
*/
var friend = hero.findNearest(hero.findFriends());
var yi = friend.pos.y - hero.pos.y;
while(true) {
// hero.move({'x':friend.pos.x, 'y': friend.pos.y - yi});
hero.moveXY(friend.pos.x, friend.pos.y - yi);
}
- Alright so first of all I realize I wasnāt accounting for the offset and thatās why many of my attempts failed. in previous levels I noticed arrays set by names, so for example
/*while (true) {
var names = ["Tharin", "Hattori"];
hero.moveXY(names[0].pos.x, names[1].pos.y);
}*/
May I ask what I did wrong in defining Tharin and Hattori in their own variables? Is it because I didnāt find out if they exist? or didnāt use a find function to declare Tharin and Hattori?
- Next is there any easier way to figure out why exactly each number is in a array short of doing this:
/*var friends = hero.findFriends();
var i = 0;
var friend = friends[i];
while (i < friends.length){
friend = friends[i];
hero.say(friend);
i++;
}
*/
/* [0]"Amara", [1]"Senick", [2]"Pender", [3]"Kleene", [4]"Tharin", [5]"Omarn", [6]"Hattori", [7]"Anya", [8]"Hushbaum", [9]"Naria" (possibly try moving in sync with these)
*/
and finding out what each number would correlate to name wise?
- How do I get a function to return a number?
function iy() {
while (i < friends.length) {
friend = friends[i];
if (friend.pos.x == hero.pos.x) {
return friend.pos.x;
} else {
i++;
}
}
}
later on I set function iy() to a variable but it wasnāt returning a numberā¦ Iāve looked back on some of my previous code examples but couldnāt find a point of reference (maybe I overlooked it)
- Iāve seen before code listed as spoilers where you have to click to expand it, how do I go about doing that?
That about sums up my questions, thank you in advance!