LoudPacks Posted December 29, 2015 Posted December 29, 2015 (edited) 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, 2015 by LoudPacks 4
Gold Scripts Posted December 29, 2015 Posted December 29, 2015 (edited) 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, 2015 by Gold Scripts
Mr Pro Pop Posted September 27, 2016 Posted September 27, 2016 if (item.getName().matches(".*\\d+.*")) { Nice one but i didnt understand what does this mean! Could you please explain it to me ? @@LoudPacks
LoudPacks Posted September 27, 2016 Author Posted September 27, 2016 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. 1
Mr Pro Pop Posted September 27, 2016 Posted September 27, 2016 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 ;)