Jump to content

Ring of wealth teleport


LoudPacks

Recommended Posts


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
Link to comment
Share on other sites

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
Link to comment
Share on other sites

  • 8 months later...

 


		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
Link to comment
Share on other sites

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 ;)

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

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