toxicity959 Posted December 4, 2017 Share Posted December 4, 2017 (edited) EDIT: Thanks to @HeyImJamie and @Explv for pointing out that this was much more complicated than necessary. This snippet accomplishes the same but more efficiently and reliably than my own method: RS2Object furnace = objects.closest("Furnace"); if(getInventory().interact("Use", "Item") && getObjects().closest("Furnace") != null && getObjects().closest("Furnace").interact("Use")) { //Do things here } ----- While working on a script, I noticed that calling entity.interact() to use an object on an entity, such as in the case of using an item on a furnace to open the crafting interface, would occasionally (for me, more often than not) click on players standing in front of the furnace, rather than on the furnace itself. Although the method was clicking inside the furnace, players standing in front of the furnace would take priority, and I would end up using my item on the player standing in front of the furnace, resulting in a "Nothing interesting happens." message. I solved this problem using the following snippet: RS2Object furnace = objects.closest("Furnace"); if (!furnace.isVisible()) camera.toEntity(furnace); furnace.hover(); sleep(random(100, 500)); if(mouse.getEntitiesOnCursor().size() == 1 && mouse.getEntitiesOnCursor().get(0).equals(furnace)) { mouse.click(false); //Do things here } This simply moves the mouse over the furnace, then checks if the furnace is the only thing under the mouse. If this is true, then it will interact with the furnace, and then continue normally. If not, this cycle of the loop will be complete, and the next cycle will move the mouse once more and check again. This method has proven successful over many hours of testing my script, and has completely eliminated the "Nothing interesting happens." message. Edited December 4, 2017 by toxicity959 Quote Link to comment Share on other sites More sharing options...
HeyImJamie Posted December 4, 2017 Share Posted December 4, 2017 Why would you not just use the interact method with a String, such as "Use"? Quote Link to comment Share on other sites More sharing options...
Explv Posted December 4, 2017 Share Posted December 4, 2017 8 minutes ago, toxicity959 said: While working on a script, I noticed that calling entity.interact() to use an object on an entity, such as in the case of using an item on a furnace to open the crafting interface, would occasionally (for me, more often than not) click on players standing in front of the furnace, rather than on the furnace itself. Although the method was clicking inside the furnace, players standing in front of the furnace would take priority, and I would end up using my item on the player standing in front of the furnace, resulting in a "Nothing interesting happens." message. I solved this problem using the following snippet: RS2Object furnace = objects.closest("Furnace"); if (!furnace.isVisible()) camera.toEntity(furnace); furnace.hover(); sleep(random(100, 500)); if(mouse.getEntitiesOnCursor().size() == 1 && mouse.getEntitiesOnCursor().get(0).equals(furnace)) { mouse.click(false); //Do things here } This simply moves the mouse over the furnace, then checks if the furnace is the only thing under the mouse. If this is true, then it will interact with the furnace, and then continue normally. If not, this cycle of the loop will be complete, and the next cycle will move the mouse once more and check again. This method has proven successful over many hours of testing my script, and has completely eliminated the "Nothing interesting happens." message. This is what you should be doing: if (getObjects().closest("Furnace").interact("Smelt")) { new ConditionalSleep(5000) { @Override public boolean condition() { return getWidgets().getWidgetContainingText("What would you like to smelt?") != null; } }.sleep(); } Quote Link to comment Share on other sites More sharing options...
toxicity959 Posted December 4, 2017 Author Share Posted December 4, 2017 15 minutes ago, Explv said: This is what you should be doing: if (getObjects().closest("Furnace").interact("Smelt")) { new ConditionalSleep(5000) { @Override public boolean condition() { return getWidgets().getWidgetContainingText("What would you like to smelt?") != null; } }.sleep(); } 23 minutes ago, HeyImJamie said: Why would you not just use the interact method with a String, such as "Use"? Because I didn't realize I could just use "Use" as my interact argument (whoops!). Here I was thinking I was so clever with my workaround. Thanks guys, I'll update OP to reflect my mistake for posterity. 1 Quote Link to comment Share on other sites More sharing options...