Dab in a Lab Posted September 20, 2018 Share Posted September 20, 2018 I finished figuring out how to determine which of the same kind of rocks my bot is mining (eg. determine which of the two iron rocks I'm currently mining) but I currently can't get the bot to detect if the rock has been mined or not. I'm using a check with the depleted rock ID, but its not picking up on it. I know its better to use color as a check for mining, but I'm wanting to use IDs for the meantime while I finish writing everything else and then deal with the color checks. Can I use IDs as a check? I've tried searching for source codes to see how other people have dealt with it, but couldn't find any. Quote Link to comment Share on other sites More sharing options...
Chris Posted September 20, 2018 Share Posted September 20, 2018 1 hour ago, Dab in a Lab said: I finished figuring out how to determine which of the same kind of rocks my bot is mining (eg. determine which of the two iron rocks I'm currently mining) but I currently can't get the bot to detect if the rock has been mined or not. I'm using a check with the depleted rock ID, but its not picking up on it. I know its better to use color as a check for mining, but I'm wanting to use IDs for the meantime while I finish writing everything else and then deal with the color checks. Can I use IDs as a check? I've tried searching for source codes to see how other people have dealt with it, but couldn't find any. Lend me a account and I can post an open source snippet for everyone 1 Quote Link to comment Share on other sites More sharing options...
Dab in a Lab Posted September 20, 2018 Author Share Posted September 20, 2018 32 minutes ago, Chris said: obj.getModifiedColours() == null Lend me a account and I can post an open source snippet for everyone Just pmed account info Quote Link to comment Share on other sites More sharing options...
Chris Posted September 20, 2018 Share Posted September 20, 2018 1 hour ago, Dab in a Lab said: I finished figuring out how to determine which of the same kind of rocks my bot is mining (eg. determine which of the two iron rocks I'm currently mining) but I currently can't get the bot to detect if the rock has been mined or not. I'm using a check with the depleted rock ID, but its not picking up on it. I know its better to use color as a check for mining, but I'm wanting to use IDs for the meantime while I finish writing everything else and then deal with the color checks. Can I use IDs as a check? I've tried searching for source codes to see how other people have dealt with it, but couldn't find any. This is what I have come up with two_ore_spawn area private Area two_ore_spawn = new Area(3175, 3366, 3175, 3368); private boolean newRock; //If we stopped animating OR newRock is TRUE if (!myPlayer().isAnimating() || newRock){ //Object filter for: hasOre AND inside the specified area RS2Object rock = getObjects().closest(obj -> Rock.IRON.hasOre(obj) && two_ore_spawn.contains(obj.getPosition())); //If rock type exists && we clicked it if (rock != null && rock.interact("Mine")){ //Set newRock to FALSE if we have just clicked it! newRock = false; log("Clicked on: " + rock.getName() + " " + rock.getPosition()); //Sleep until condition evaluates to true for 5 seconds and looping the condition every 1.5 seconds if (new ConditionalSleep(5000, 1500) { @Override public boolean condition() throws InterruptedException { return !rock.exists(); } }.sleep()){ log("Conditional sleep evaluated to true!"); //If the conditional sleep evaluated true then we set newRock to TRUE newRock = true; } } } Explv's Snippet Data import org.osbot.rs07.api.model.Entity; public enum Rock { CLAY(new short[]{6705}), COPPER(new short[]{4645, 4510}), TIN(new short[]{53}), IRON(new short[]{2576}), SILVER(new short[]{74}), COAL(new short[]{10508}), GOLD(new short[]{8885}), MITHRIL(new short[]{-22239}), ADAMANTITE(new short[]{21662}), RUNITE(new short[]{-31437}); private short[] colours; Rock(final short[] colours) { this.colours = colours; } public boolean hasOre(final Entity rockEntity) { if (rockEntity.getDefinition() == null) { return false; } short[] colours = rockEntity.getDefinition().getModifiedModelColors(); if (colours == null) { return false; } for (short rockColour : this.colours) { for (short entityColour : colours) { if (rockColour == entityColour) { return true; } } } return false; } } 1 1 Quote Link to comment Share on other sites More sharing options...
IDontEB Posted September 20, 2018 Share Posted September 20, 2018 (edited) edit: nvm Chris explained it and posted code. Edited September 20, 2018 by IDontEB Quote Link to comment Share on other sites More sharing options...
Chris Posted September 20, 2018 Share Posted September 20, 2018 Hope it helps Quote Link to comment Share on other sites More sharing options...
Dab in a Lab Posted September 20, 2018 Author Share Posted September 20, 2018 6 minutes ago, Chris said: Hope it helps Thank you so much! 1 Quote Link to comment Share on other sites More sharing options...
FrostBug Posted September 20, 2018 Share Posted September 20, 2018 (edited) 5 hours ago, Dab in a Lab said: I finished figuring out how to determine which of the same kind of rocks my bot is mining (eg. determine which of the two iron rocks I'm currently mining) but I currently can't get the bot to detect if the rock has been mined or not. I'm using a check with the depleted rock ID, but its not picking up on it. I know its better to use color as a check for mining, but I'm wanting to use IDs for the meantime while I finish writing everything else and then deal with the color checks. Can I use IDs as a check? I've tried searching for source codes to see how other people have dealt with it, but couldn't find any. From your explanation, it sounds like you're expecting your RS2Object instance (from before depletion) to change ID, which it never will. You will have to grab the new RS2Object instance, as the depleted rock is generally speaking a new different object. As an alternative to checking the depletion ID, you could check if your non-depleted object instance has stopped existing with the exists() method. Edited September 20, 2018 by FrostBug 1 Quote Link to comment Share on other sites More sharing options...
Dab in a Lab Posted September 20, 2018 Author Share Posted September 20, 2018 7 hours ago, FrostBug said: From your explanation, it sounds like you're expecting your RS2Object instance (from before depletion) to change ID, which it never will. You will have to grab the new RS2Object instance, as the depleted rock is generally speaking a new different object. As an alternative to checking the depletion ID, you could check if your non-depleted object instance has stopped existing with the exists() method. Ya, that’s exactly what I was doing. I was relying on my script to pick up on the new rock ID from the one instance. I’ve got everything working great now though with Chris’s help. Quote Link to comment Share on other sites More sharing options...