loopback Posted August 4, 2017 Share Posted August 4, 2017 (edited) So I accidentally deleted my broken mining script and am trying to re-create it from memory, and so far so good. However I am trying to check the color of the rock before I mine it and I am missing something. public enum Rock { CLAY(6705), COPPER(4645), TIN(53), IRON(2576), SILVER(74), COAL(10508), GOLD(8885), MITHRIL(-22239), ADAMANTITE(21662), RUNITE(-31437); private final short COLOUR; Rock(final int COLOUR) { this.COLOUR = (short) COLOUR; } public boolean hasOre(final RS2Object object) { if (object == null || object.getDefinition().getModifiedModelColors() == null || !"Rocks".equals(object.getName())) { return false; } for (final short colour : object.getDefinition().getModifiedModelColors()) { if (colour == this.COLOUR) { return true; } } return false; } } public void Minesomething() throws InterruptedException { goldRock = getObjects().closest( obj -> Rock.GOLD.hasOre(obj)); if (goldRock != null && goldRock.interact("Mine")) { new Sleep(() -> isAnimating() || !Rock.GOLD.hasOre(goldRock), 10000).sleep(); } } That is the code I am having trouble with, It says can not resolve symbol goldRock. And I cant remember how I had it in my original working script. Any pointers? Edited August 4, 2017 by loopback typo Quote Link to comment Share on other sites More sharing options...
Rekt Posted August 4, 2017 Share Posted August 4, 2017 if (object == null || object.getDefinition().getModifiedModelColors() == null || !"Rocks".equals(object.getName())) { Should be Rock? Quote Link to comment Share on other sites More sharing options...
Easy Posted August 4, 2017 Share Posted August 4, 2017 (edited) You haven't declared a goldRock variable. You're trying to reference it but it doesn't exist, thus the "Symbol cannot be found" error. What you need to do is declare a variable of the same type as the return value from getObjects#closest. The return type is RS2Object, so the code should look like: RS2Object goldRock = getObjects().closest( obj -> Rock.GOLD.hasOre(obj)); Edited August 4, 2017 by Easy 1 Quote Link to comment Share on other sites More sharing options...
loopback Posted August 4, 2017 Author Share Posted August 4, 2017 18 minutes ago, Easy said: You haven't declared a goldRock variable. You're trying to reference it but it doesn't exist, thus the "Symbol cannot be found" error. What you need to do is declare a variable of the same type as the return value from getObjects#closest. The return type is RS2Object, so the code should look like: RS2Object goldRock = getObjects().closest( obj -> Rock.GOLD.hasOre(obj)); This is it! Thank you I knew it was something obvious. This is what I get for cleaning my hard drive at 2am then trying to recreate something from memory. Thanks Quote Link to comment Share on other sites More sharing options...