I’m working on a script that crafts earth battlestaffs. The script currently selects an orb and then a battlestaff from my inventory. However, I’m facing an issue where the script always selects the first battlestaff in the inventory instead of the one closest to the orb.
the current script interacts with first one
I want it to interact with the last one
Item battleStaff = inventory.getItem(ITEM_BATTLESTAFF);
Item earthOrb = inventory.getItem(ITEM_EARTHORB);
if (battleStaff.interact(ACTION_SELECTITEM)) {
sleep(random(400, 600));
if (earthOrb.interact(ACTION_SELECTITEM)) {
sleep(random(700, 900));
return true;
} else {
log("Error: Failed to interact with Earth Orb.");
}
} else {
log("Error: Failed to interact with Battle Staff.");
}