Vurqol Posted January 29, 2019 Share Posted January 29, 2019 (edited) How would I go about swapping items and how could I make the script interact with two inventory slots? Help is much appreciated! Thanks! Edited February 1, 2019 by Vurqol Solved Quote Link to comment Share on other sites More sharing options...
Durky Posted January 29, 2019 Share Posted January 29, 2019 getInventory().interact(getInventory().getSlotForNameThatContains(Item1Name), "Use"); getInventory().interact(28, "Use"); // Slotid = 11 if (getInventory().contains(item1Name) && getInventory().contains(item2Name)) { getInventory().getItem(item1Name).interact("Use"); sleep(250); // slight delay to allow the script to select it, should be a conditional for "lagg" etc. getInventory().getItem(item2Name).interact("Use"); 3 options above. Now if you want to drag the item and switch it with something else you're going to need to use the continualClick(MouseDestination destination, org.osbot.rs07.utility.Condition condition) Quote Link to comment Share on other sites More sharing options...
Ragnar Lothbrok Posted January 29, 2019 Share Posted January 29, 2019 30 minutes ago, Durky said: getInventory().interact(getInventory().getSlotForNameThatContains(Item1Name), "Use"); getInventory().interact(28, "Use"); // Slotid = 11 if (getInventory().contains(item1Name) && getInventory().contains(item2Name)) { getInventory().getItem(item1Name).interact("Use"); sleep(250); // slight delay to allow the script to select it, should be a conditional for "lagg" etc. getInventory().getItem(item2Name).interact("Use"); 3 options above. Now if you want to drag the item and switch it with something else you're going to need to use the continualClick(MouseDestination destination, org.osbot.rs07.utility.Condition condition) Please perform checks on your methods: if (getInventory().contains(ITEM1) && getInventory().contains(ITEM2)) { if (!getInventory().isItemSelected()) { // Select Item then sleep until an item is selected } else { // Use Items together then sleep until no item is selected } } I just wrote this up so I haven't tested this or verified that the method names are correct but you should get the gist. 1 Quote Link to comment Share on other sites More sharing options...
Vurqol Posted January 30, 2019 Author Share Posted January 30, 2019 (edited) I'm currently trying something like this getInventory().interact(23); log("Slot 23 Selected"); new ConditionalSleep(1500) { @Override public boolean condition() throws InterruptedException { return inventory.isItemSelected(); } }.sleep(); getInventory().interact(28); log("Slot 28 Selected"); new ConditionalSleep(1500) { @Override public boolean condition() throws InterruptedException { return !inventory.contains(""); And while I have gone ahead and tried "Use" on both interacts. It's only interacting with one of them and rolling through it saying that it has executed the other but only doing the first, The code works when I use another interact but instead I don't use the second slot. Making what I'm after just a little bit inefficient Note, both slots only require a left click **edit I have taken another look at the API and noticed that there's a few "interacts with first item matched" Is there a "last item matched" ? Edited January 30, 2019 by Vurqol Quote Link to comment Share on other sites More sharing options...
Durky Posted January 30, 2019 Share Posted January 30, 2019 12 hours ago, Ragnar Lothbrok said: Please perform checks on your methods: if (getInventory().contains(ITEM1) && getInventory().contains(ITEM2)) { if (!getInventory().isItemSelected()) { // Select Item then sleep until an item is selected } else { // Use Items together then sleep until no item is selected } } I just wrote this up so I haven't tested this or verified that the method names are correct but you should get the gist. i wasn't writing it for him, also the comments clearly state you should be using a conditional sleep, inwhich you should be delaying until item1 is selected. Thanks thou Quote Link to comment Share on other sites More sharing options...
Durky Posted January 30, 2019 Share Posted January 30, 2019 (edited) 2 hours ago, Vurqol said: I'm currently trying something like this getInventory().interact(23); log("Slot 23 Selected"); new ConditionalSleep(1500) { @Override public boolean condition() throws InterruptedException { return inventory.isItemSelected(); } }.sleep(); getInventory().interact(28); log("Slot 28 Selected"); new ConditionalSleep(1500) { @Override public boolean condition() throws InterruptedException { return !inventory.contains(""); And while I have gone ahead and tried "Use" on both interacts. It's only interacting with one of them and rolling through it saying that it has executed the other but only doing the first, The code works when I use another interact but instead I don't use the second slot. Making what I'm after just a little bit inefficient Note, both slots only require a left click **edit I have taken another look at the API and noticed that there's a few "interacts with first item matched" Is there a "last item matched" ? i'm kind of confused, could you maybe try to explain it a different way? **note sorry for the multi post, multi quote wasn't functioning properly for me. Edited January 30, 2019 by Durky Quote Link to comment Share on other sites More sharing options...
Vurqol Posted January 30, 2019 Author Share Posted January 30, 2019 So I'm trying to use a specific inventory slot on another specific inventory slot. However there are 14 of each of the item in the inventory. There is simply no interface to "Make all" So having the items next too each other in the inventory and then having the script execute it so the slots are used on each other is better Or else it's just using slot 1 and slot 15. which is half the inventory away. These items also move around and it's more effective too have the item in the bottom two slots as you can spam it and make two in a tick if done correctly, this cannot be achieved if they are half an inventory away and such it's inefficient. Quote Link to comment Share on other sites More sharing options...
Vurqol Posted February 1, 2019 Author Share Posted February 1, 2019 (edited) Still looking for help if anyone can Edited February 1, 2019 by Vurqol Quote Link to comment Share on other sites More sharing options...
Vurqol Posted February 1, 2019 Author Share Posted February 1, 2019 @Durky Fixed it... I was going off the basis that slot 28 in the inventory is 28. However Java starts at 0. Making it 27. Quote Link to comment Share on other sites More sharing options...
ItPoke Posted February 1, 2019 Share Posted February 1, 2019 (edited) On 1/30/2019 at 1:22 AM, Vurqol said: getInventory().interact(23); log("Slot 23 Selected"); new ConditionalSleep(1500) { @Override public boolean condition() throws InterruptedException { return inventory.isItemSelected(); } }.sleep(); getInventory().interact(28); log("Slot 28 Selected"); new ConditionalSleep(1500) { @Override public boolean condition() throws InterruptedException { return !inventory.contains(""); You should really not do conditional sleeps like that, since the interact function will not go on before it returns either a fail or a success. Since the sleeps will just pass instant if the interact was a success and if the interact was a failure then they will just delay your script for 1500 ms and then continue, even though it failed. Which is not good... Do if statements instead (like Ragnar Lothbrok said), this way you can break out of the loop or start over if it fails instead of just delaying it and expecting it to always work, example: if (getInventory().interact(23)) { log("Slot 23 Selected"); // Continue it worked! } else { log("Failed to select slot 23!"); // We failed lets break out of the loop and try again! return; } Do this for both slots and then you can do an conditional sleep statement in the end to check if the inventory contains the item or not to see if the whole interaction went well or not. This is just to wait for the animation to finish up since the interact will fishish first. You should always consider why you would need a sleep at all, so you don't end up using them wrong! Since you wont be waiting for the interact function it already pauses and won't continue before it returns a fail or success. But you would like to do a sleep when you have preformed the action because the game does an animation(delay) before the action happens and the items are combined or changed. Edited February 1, 2019 by ItPoke Quote Link to comment Share on other sites More sharing options...