Jump to content

Widgets are annoying or am I dumb?


Jueix

Recommended Posts

So I'm randomly coding scripts that I feel like I may need for my bot farm and I hate dealing with widgets / interfaces due to my bots spamming the item a few times before realising the interface is actually up. 

Here's the code I have for the last room in stronghold of security for floor 1. (Made a bot that does stronghold yes I am a noob and to lazy to manually do it). 

[code]

if(WarEnd.contains(myPlayer())) {

log("We are in the end room now");

RS2Widget widget1 = getWidgets().get(579, 17);

 

if (dialogues.isPendingContinuation() && WarEnd.contains(myPlayer())) {

log("JSS Floor 1: Interacting with chest dialogs");

dialogues.clickContinue();

}

 

Item coins = getInventory().getItem("Coins");

if(coins.getAmount() >= 2000) {

log("Detected coins in inventory going to floor 2");

RS2Object ladder = getObjects().closest(o -> o != null && o.getName().equals("Ladder") && o.getPosition().equals(new Position(1902, 5222, 0)));

if (ladder != null && !myPlayer().isAnimating() && !myPlayer().isMoving() && !dialogues.isPendingContinuation()) {

ladder.interact("Climb-down");

Timing.waitCondition(

() -> getWidgets().get(579, 17).isVisible(),

30000);

}

 

if(widget1 != null) {

if (widget1.isVisible()) {

ScriptStatus = "Should be heading to floor 2.";

if (widget1.interact()) {

Floor = "Catacomb of Famine";

ScriptStatus = "Interacting with gate 1";

Timing.waitCondition(

() -> !WarEnd.contains(myPlayer()),

10000);

}

}

}

}

if(coins.getAmount() < 2000) {

RS2Object giftofpeace = getObjects().closest(o -> o != null && o.getName().equals("Gift of Peace") && o.getPosition().equals(new Position(1907, 5222, 0)));

if (giftofpeace != null && !myPlayer().isAnimating() && !myPlayer().isMoving() && !inventory.contains("Coins") && !dialogues.isPendingContinuation()) {

giftofpeace.interact("Open");

ScriptStatus = "Interacting with gift of peace";

log("JSS Floor 1: Attempting Interaction with gift of peace");

/*try {

discordMessage("redacted", "Floor 1 has now been completed, See that wasn't hard to code was it. Now code floor 2 lazy ass noob!", "Jueixs Stronghold of Security");

} catch (IOException e) {

// TODO Auto-generated catch block

e.printStackTrace();

}*/

Timing.waitCondition(() -> dialogues.isPendingContinuation(), 10000);

}

}

[/code]

So Basically it will click the ladder 3 - 5 times (the interface will open and it will close the interface by clicking the ladder again and after a while it will realise the interface is finally open and go down. I've also placed the code for the ladder at the top of the script and it will still do it. 

Link to comment
Share on other sites

Why not use the webwalker? Pretty sure it can solve the whole stronghold with 1 line of code :D
Only thing you might wanna do is break the webwalking when you need to eat and continue after

Also code like this:

Timing.waitCondition(() -> getWidgets().get(579, 17).isVisible(),30000);

Can cause a lot of errors.
Make sure to null check a widget before checking if it's visible.
Also it's a lot better to not use any widgets IDs as they can change, use widgetsContainingtext instead :)

Edited by Khaleesi
Link to comment
Share on other sites

You could set areas before and after each door. if in the area before the door, click on the door. if in the area after the door run to the next area before the next door.

before that have it check if in dialogue and if so start a function to handle dialogue. if not in dialogue do the moving around. This is a sample from my HandleDialogue function I made for a quest script.

 

public int onLoop() throws InterruptedException {
	if (getDialogues().inDialogue()) {
        HandleDialogue();
    } else {
		//move from area to area and click doors
    }
    return 602;
}

void HandleDialogue() throws InterruptedException {
	if (getDialogues().isPendingContinuation()) {
		if (getDialogues().clickContinue()) {sleep(random(200,600));}
	} else if (getDialogues().isPendingOption()) {
		if (getDialogues().selectOption("Yes.")) {sleep(random(400,3500));}
			else if (getDialogues().selectOption("I wanted to use your anvils.")) {sleep(random(400,3500));}
            else if (getDialogues().selectOption("No, he doesn't look fat")) {sleep(random(400,3500));}
            else if (getDialogues().selectOption("Do you want me to pick an armour colour for you?")) {sleep(random(400,3500));}
            else if (getDialogues().selectOption("What about a different colour?")) {sleep(random(400,3500));}
            else if (getDialogues().selectOption("I have some orange armour here.")) {sleep(random(400,3500));}
    }
}

Not sure whats going on with the spacing up there lol

 

Edited by Alakazizam
Link to comment
Share on other sites

4 hours ago, Khaleesi said:

Why not use the webwalker? Pretty sure it can solve the whole stronghold with 1 line of code :D
Only thing you might wanna do is break the webwalking when you need to eat and continue after

Also code like this:

Timing.waitCondition(() -> getWidgets().get(579, 17).isVisible(),30000);

Can cause a lot of errors.
Make sure to null check a widget before checking if it's visible.
Also it's a lot better to not use any widgets IDs as they can change, use widgetsContainingtext instead :)

I did try web walking in the stronghold but it doesn't seem to work for me and I don't know why. 

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