im using this wilderness looting script that takes items from the ground. it works pretty well except when it finds an item that is so far away or behind a hill so that the take menu is not available and it just gets stuck. how would i fix this to walk towards the item if it is too far away? or at least ignore if it cant actually be picked up.
for(int i = 0;i<P2PLoot.length;i++){
for(GroundItem g: groundItems.getAll()){
if(g.getName().equals(P2PLoot[i])&&g !=null){
if(inventory.isFull()||skills.getDynamic(Skill.HITPOINTS)<=6||myPlayer().isUnderAttack()){
break;
}
log("found item!"+ P2PLoot[i]);
GroundItem a= groundItems.closest(P2PLoot[i]);
a.interact("Take");
sleep(300);
do{
sleep(200);
}while(myPlayer().isAnimating());
breaker = true;
break;
}
}