Jump to content

Ring of wealth teleport


Recommended Posts

Posted (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 by LoudPacks
  • Like 4
Posted (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 by Gold Scripts
  • 8 months later...
Posted

 


		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.

  • Like 1
Posted

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

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...