September 20, 20187 yr 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.
September 20, 20187 yr 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
September 20, 20187 yr Author 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
September 20, 20187 yr 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; } }
September 20, 20187 yr edit: nvm Chris explained it and posted code. Edited September 20, 20187 yr by IDontEB
September 20, 20187 yr 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, 20187 yr by FrostBug
September 20, 20187 yr Author 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.
Create an account or sign in to comment