Jump to content
jelleplomp

interface help

Recommended Posts

Hi everybody,

 

I need some help, I'm trying to make a monkfighter that will auto heal itself on the monk itself,

now i already have this bit of code: 

private void heal() throws InterruptedException {
	  NPC Monk = (NPC)this.npcs.closest(new String[] { "Monk" });
		if(Monk != null && !myPlayer().isUnderAttack() && !Monk.isUnderAttack()) {
			Monk.interact(new String[] { "Talk-to" });
			this.status = "healing at Monk";
		    getInterfaces().get(231).getChild(2).interact(new String[] { "continue" });
		    getInterfaces().get(219).getChild(1).interact(new String[] { "can" });
		    sleep(random(200,300));
		    getInterfaces().get(217).getChild(2).interact(new String[] { "continue" });
		    sleep(random(200,300));
		    getInterfaces().get(231).getChild(2).interact(new String[] { "continue" });
		    sleep(random(1000, 1500));
		}
	}

but in the loop when its opening the interfaces and starting to interact at "can", the onloop method refers back to this method so it will all start over again, meaning it will never go further than this line:

getInterfaces().get(231).getChild(2).interact(new String[] { "continue" });
 

so how do i do this?

thanks in advance,

 

Jelleplomp

Link to comment
Share on other sites

You are getting an NPE error (nullpointer Exception)

 

If (231,2) doesn't get found it will return null.

So you do null.interact("Continue"); (and you can't really interact with something that doesn't exist right?)

 

You should stop using interfaces since the are deprecated.

Use RS2Widget instead.

 

You basicly to this:

RS2Widget chat1 = widgets.get(231,2)
if(chat1 != null && chat1.isVisible())
   chat1.interact("Continue");

Why are you using: (Did you decompile code? Decompilers generate this kind of code)

.interact(new String[] { "Continue" });

You can just do:

.interact("Continue");

Goodluck!

Khaleesi

Edited by Khaleesi
Link to comment
Share on other sites

Umm, this should work; // Didn't test

if (!myPlayer().isInteracting(monk))) { // NOT INTERACTING
     if (monk != null) { // IF EXISTS
         if (monk.isVisible()) { // IS VISIBLE
             if (!dialogues.inDialogue()) { // NOT IN DIALOGUE
        monk.interact("Talk-to"); // INTERACTS
        log("Talking to monk"); // LOG
        sleep(random(500, 900)); // SLEEPS

}
}
} else if (dialogues.inDialogue()) { // IF IN DIALOGUE
               dialogues.clickContinue(); // CLICKS ON THE CONTINUE
               sleep(random(600, 1000)); //  SLEEPS
               dialogues.selectOption("Ok"); // GIVE THIS AN OPTION
               sleep(random(2500, 3500)); // SLEEPS
             }
} 
Link to comment
Share on other sites

Not sure why you are casting NPC or why you are using arrays in the constructors.

 

Try this:

NPC monk = npcs.closest("Monk");
if(monk != null){
monk.interact("Talk-to");
//Conditional sleep until dialogues.isInDialogue();
dialogues.completeDialogue("can");
}

Dialogues API:

http://osbot.org/api/org/osbot/rs07/api/Dialogues.html

 

 

 

 

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.

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