Jump to content

[Solved] Problem trying to get object for nightmare zone powerup orbs


Greasy Nigel

Recommended Posts

Hey guys, so I want to interact with some of the powerups in nmz. This is what ive written:

 

RS2Object powerup = getObjects().closest(n -> powerups.contains(n.getName()));

if (powerup != null) {

powerup.interact();

Sleep.sleepUntil(() -> powerup == null || !powerup.hasAction("Activate"), 5000);

}

Where powerups is a list containing the names of the powerups that I want to interact with.

I've tried powerup as an NPC as well as a RS2Object, but no matter what, they are always null.

Any ideas?

 

SOLVED (see below):
I decided I might as well share the snippet I eventually used in case it is of use to anyone else:

 

    List<String> powerups = Arrays.asList("Zapper", "Recurrent damage");

	public boolean listContainsStringContaining(List<String> list, String string) {
    	for (String listString : list) {
    		if (string.contains(listString)) {
    			return true;
    		}
    	}
    	return false;
    }
   
   	public void activatePowerups() {
   		RS2Object powerup = getObjects().closest(n -> listContainsStringContaining(powerups, n.getName()));
   		if (powerup != null) {
   			powerup.interact();
   			Sleep.sleepUntil(() -> powerup == null || !powerup.hasAction("Activate"), 5000);
   			log(powerup.getName());
   		}
   	}

 

Edited by Greasy Nigel
Solved
Link to comment
Share on other sites

  • Greasy Nigel changed the title to [Solved] Problem trying to get object for nightmare zone powerup orbs

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...