GameObjects are static, interactable objects in the world (e.g., trees, doors, furnaces).
GameObject tree = GameObjects.closest("Tree");
Always check if the object is not null and on screen before interacting. Filter by both name and action when necessary to avoid misclicks:
GameObject bankBooth = GameObjects.closest(obj -> obj != null
&& obj.hasAction("Bank")
&& obj.getName().equals("Bank booth"));
Example:
if (tree != null && tree.isOnScreen()) {
if (tree.interact("Chop down")) {
sleepUntil(() -> !tree.exists() || !getLocalPlayer().isAnimating(), 5000);
}
}
NPCs represent mobile non-player characters, like shopkeepers, guards, and quest givers.
NPC banker = NPCs.closest("Banker");
Check for reachability with canReach() if movement is involved.
NPC shopkeeper = NPCs.closest(npc -> npc.hasAction("Trade") && npc.getName().equals("Shop keeper"));
Example:
if (banker != null && banker.interact("Bank")) {
sleepUntil(Bank::isOpen, 5000);
}
sleepUntil() pauses the script until a condition is met or a timeout is reached.
sleepUntil(() -> !Players.getLocal().isAnimating(), Calculations.random(1000,1500));
other useful api's:
API Class Example Use
Inventory Inventory.contains("Logs")
Bank Bank.depositAllExcept("Axe")
Walking Walking.walk(destination)
Map Map.getWalking().walk(targetTile)
Skills Skills.getExperience(Skill.WOODCUTTING)