let finderNear = () => {
const friend = hero.findNearest(hero.findFriends());
const enemy = hero.findNearest(hero.findEnemies());
const item = hero.findNearest(hero.findItems());
if(friend){return friend;}
if(enemy){return enemy;}
if(item){return item;}
};
I’m trying to make a function that will find nearby stuff.
is there a way to call this function and assign different return statements to different variables.
for example.
while(true) {
let nearStuff = finderNear();
if(nearStuff){
hero.moveXY(x.pos.x, x.pos.y);
}
}
when done like this, the function finds everything, but I would like to assign items, enemies and friends found to different variables
When I use that If statement ( if(nearStuff) ), it moves to everything.
is there a way to declare an if statement that will only focus on items, enemies, or friends?
I can separate this into 3 functions and solve what I’m trying to achieve but I’m wondering if there is a way to combine everything into one function and use what I need, depending on the level.
I hope that makes sense