Jump to content

Interact with interface.


Shnocky

Recommended Posts

my first snippet biggrin.png

 

i was messing around trying to write a method to interact with an interface, i came up with this. It seems to work good smile.png

 

updated, Thanks Swizzbeat & Pseudo for the updated methods ! smile.png

public boolean interactWithInterface(int parent, int child, String action) throws InterruptedException {
        RS2InterfaceChild ic = this.client.getInterface(parent).getChild(child);
        return ic != null && ic.isVisible() && ic.interact(action);
    }

the way you use it:

interactWithInterface(parentId, ChildId, Action);

example of use:

interactWithInterface(304, 3, "Make X");

this would click the make x option on the fletching interface.

 

Hope it comes in handy smile.png

Edited by Shnocky
Link to comment
Share on other sites

I'm not sure why your settings up a child variable? Why not just do (as well as naming your variables with the correct conventions):

private boolean interactWithInterface(int parent, int child, String interaction) throws InterruptedException {
	RS2Interface interface = client.getInterface(parent);
	if (interface != null && interface.isVisible()) {
		interface.getChild(child).interact(interaction);
		return true;
	}
	return false;
}

isVisible() already checks for child elements being drawn, so there's no reason to make am RS2InterfaceChild variable. A regular RS2Interface works fine.

Edited by Swizzbeat
  • Like 1
Link to comment
Share on other sites

I'm not sure why your settings up a child variable? Why not just do (as well as naming your variables with the correct conventions):

private boolean interactWithInterface(int parent, int child, String interaction) throws InterruptedException {
	RS2Interface interface = client.getInterface(parent);
	if (interface != null && interface.isVisible()) {
		interface.getChild(child).interact(interaction);
		return true;
	}
	return false;
}

isVisible() already checks for child elements being drawn, so there's no reason to make am RS2InterfaceChild variable. A regular RS2Interface works fine.

thanks, i didn't realize that :o ill update it!

 

make that next and not Next

 

Yeah forgot that :P

Link to comment
Share on other sites

public boolean interactWithInterface(int parent, int child, String action) throws InterruptedException {
        RS2InterfaceChild ic = this.client.getInterface(parent).getChild(child);
        return ic != null && ic.isVisible() && ic.interact(action);
    }

^ Should work, I haven't tested it. Also please don't take offence at me posting this, people will be grateful for your contribution, just trying to outline how things can be done simpler/in less code with the same outcome. Good work, keep at it.

Edited by Pseudo
  • Like 1
Link to comment
Share on other sites

public boolean interactWithInterface(int parent, int child, String action) throws InterruptedException {
        RS2InterfaceChild ic = this.client.getInterface(parent).getChild(child);
        return ic != null && ic.isVisible() && ic.interact(action);
    }

^ Should work, I haven't tested it. Also please don't take offence at me posting this, people will be grateful for your contribution, just trying to outline how things can be done simpler/in less code with the same outcome. Good work, keep at it.

 

hmm, when i get a chance ill test this. And no i don't take any offence to that. just trying to give back to the community thats helped me so much :p and theres always room for improvements on code :)

Link to comment
Share on other sites

Hi guys, this is really useful thanks, but am I able to use this function for click in the chat window? i.e. "Click here to Continue" and selecting options in the menu? if so how do I set it? I can only get it to click on talk-to on the game screen.

 

also i'm struggling to see what the parent and child ids are? looked in the api but it aint helping

Edited by blood1000
Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
  • Recently Browsing   0 members

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