December 29, 201510 yr private void wealth(String option) { if (getEquipment().interact(EquipmentSlot.RING, option)) { Position current = myPlayer().getPosition(); new ConditionalSleep(1500, 2000) { @Override public boolean condition() { return !myPlayer().getPosition().equals(current); } }.sleep(); } else { for (Item item : getInventory().getItems()) { if (item != null && item.getName().contains("wealth") && item.getName().matches(".*\\d+.*")) { item.interact("wear"); new ConditionalSleep(1500, 2000) { @Override public boolean condition() { return getEquipment().isWearingItem(EquipmentSlot.RING, item.getId()); } }.sleep(); break; } } } } Edited December 29, 201510 yr by LoudPacks
December 29, 201510 yr private void wealth() { if (!getEquipment().isWearingItem(EquipmentSlot.RING, "Ring of wealth") && getEquipment().interact(EquipmentSlot.RING, "Grand exchange")) { Position current = myPlayer().getPosition(); new ConditionalSleep(1500, 2000) { @Override public boolean condition() { return !myPlayer().getPosition().equals(current); } }.sleep(); } else { for (Item item : getInventory().getItems()) { if (item != null && item.getName().contains("wealth") && item.getName().matches(".*\\d+.*")) { item.interact("wear"); new ConditionalSleep(1500, 2000) { @Override public boolean condition() { return getEquipment().isWearingItem(EquipmentSlot.RING, item.getId()); } }.sleep(); break; } } } } !getEquipment().isWearingItem(EquipmentSlot.RING, "Ring of wealth") This ensures the script doesn't attempt to teleport with a ring that has no charges. Probably isn't necessary, however nice code man! Edited December 29, 201510 yr by Gold Scripts
September 27, 20169 yr if (item.getName().matches(".*\\d+.*")) { Nice one but i didnt understand what does this mean! Could you please explain it to me ? @@LoudPacks
September 27, 20169 yr Author if (item.getName().matches(".*\\d+.*")) { Nice one but i didnt understand what does this mean! Could you please explain it to me ? @@LoudPacks It's called a regular expression, REGEX for short. Once you learn the syntax you can use it to build a regular expression that can be used to match parts of text or extract certain patterns from text. In this case, ".*\\d+.*" looks for any amount of text:" .*" followed by a number or series of numbers "\\d+", followed by any amount of text ".*" so any string that contains a number in it would be a match, for example "Amulet of glory (4)", "Amulet of glory (" is matched by the first ".*" the "4" is matched by the "\\d+" and the ")" is matched by the second ".*" but would also still match if there was no text after the 4.
September 27, 20169 yr It's called a regular expression, REGEX for short. Once you learn the syntax you can use it to build a regular expression that can be used to match parts of text or extract certain patterns from text. In this case, ".*\\d+.*" looks for any amount of text:" .*" followed by a number or series of numbers "\\d+", followed by any amount of text ".*" so any string that contains a number in it would be a match, for example "Amulet of glory (4)", "Amulet of glory (" is matched by the first ".*" the "4" is matched by the "\\d+" and the ")" is matched by the second ".*" but would also still match if there was no text after the 4. Ohh thanks bro ;)
Create an account or sign in to comment