Jump to content

New update broke script


XaLeR

Recommended Posts

So I made a script that would make gold bracelets. It was working fine on OSBot 2.4.133 but now it won't work anymore on the new update. I'm not sure why, because it's using widgets to make it and those numbers are still the same. 

Anyone has an idea why this would happen?

this is the code (Thanks Explv Tutorials)

private void make() {
    if (!smeltingRoom.contains(myPosition())) {
        getWalking().webWalk(smeltingRoom);
    } else if (isMakeScreenVisible() || isEnterAmountPromptVisible()) {
        if (makeXGold()) {
            Sleep.sleepUntil(this::isEnterAmountPromptVisible, 3000);
        }

        if (enterRandomAmount()) {
            Sleep.sleepUntil(() -> !canSmeltGoldBars() || getDialogues().isPendingContinuation(), 100_000);
        }

    } else if (useGold() & useFurnace()) {
        Sleep.sleepUntil(this::isMakeScreenVisible, 5000);
    }
}

private boolean canSmeltGoldBars() {
    return getInventory().contains("Gold bar");
}

private boolean useFurnace() {
    return getObjects().closest("Furnace").interact("Use");
}

private boolean useGold() {
    return getInventory().interact("Use","Gold bar");
}

private boolean isMakeScreenVisible() {
    return getWidgets().getWidgetContainingText("What would you like to make?") != null;
}

private boolean makeXGold() {
    return getWidgets().get(446,47).interact("Make-X");
}

// Using a custom filter here instead of getWidgetContainingText() because it ignores widgets with root id 162
private boolean isEnterAmountPromptVisible(){
    RS2Widget amountWidget = getWidgets().singleFilter(getWidgets().getAll(), widget -> widget.getMessage().contains("Enter amount"));
    return amountWidget != null && amountWidget.isVisible();
}

private boolean enterRandomAmount() {
    return getKeyboard().typeString("" + MethodProvider.random(28, 35));
}
Edited by XaLeR
Link to comment
Share on other sites

3 minutes ago, XaLeR said:

 

The moment the widget opens to make the gold bracelet, it won't interact with the bracelet to Make-X.

Maybe the script is using child/grandchild ids and perhaps these changed with Jagex working on Make-All? Just speculation, without any code i cannot help. You'll have to contact the scripter via the script thread!

Apa

  • Like 1
Link to comment
Share on other sites

58 minutes ago, XaLeR said:

edited the main post with code

Perhaps it's this line?

getWidgets().get(446,47).interact("Make-X");

Maybe the id has changed. You can check this in-game and update it, but better would be to future-proof it by using the Widget debugger to try and find a trait of this widget to identify it other than its id. There must be something to identify it from others - perhaps sprite?

(This is the reason that static ids beyond root level are not permitted on the SDN! - ids tend to change frequently, whereas text, colour or other properties are more consistent)

Edit: This method can also be adjusted:

private boolean isEnterAmountPromptVisible(){
    RS2Widget amountWidget = getWidgets().singleFilter(getWidgets().getAll(), widget -> widget.getMessage().contains("Enter amount"));
    return amountWidget != null && amountWidget.isVisible();
}

... to:

private boolean isEnterAmountPromptVisible(){
   return getWidgets().getWidgetContainingText(162, "Enter amount:") != null;
}

Apa

Edited by Apaec
Link to comment
Share on other sites

33 minutes ago, Apaec said:

Perhaps it's this line?


getWidgets().get(446,47).interact("Make-X");

Maybe the id has changed. You can check this in-game and update it, but better would be to future-proof it by using the Widget debugger to try and find a trait of this widget to identify it other than its id. There must be something to identify it from others - perhaps sprite?

(This is the reason that static ids beyond root level are not permitted on the SDN! - ids tend to change frequently, whereas text, colour or other properties are more consistent)

Edit: This method can also be adjusted:


private boolean isEnterAmountPromptVisible(){
    RS2Widget amountWidget = getWidgets().singleFilter(getWidgets().getAll(), widget -> widget.getMessage().contains("Enter amount"));
    return amountWidget != null && amountWidget.isVisible();
}

... to:


private boolean isEnterAmountPromptVisible(){
   return getWidgets().getWidgetContainingText(162, "Enter amount:") != null;
}

Apa

Thanks already for the help. I took some screenshots of the widget debugger and 446,47 still is the gold bracelet. And Sprites are -1 so i guess that will not work?

Is it possible with itemID?

 

Edited by XaLeR
Link to comment
Share on other sites

38 minutes ago, XaLeR said:

Thanks already for the help. I took some screenshots of the widget debugger and 446,47 still is the gold bracelet. And Sprites are -1 so i guess that will not work?

Is it possible with itemID?

 

If those still are the gold bracelet ids then i'm not sure what to suggest :/ Try using log statements to pinpoint exactly which line isn't working. Also, maybe position is the best way to determine this widget from its horizontal counterparts? Using position would mean adding other bracelets in future would be simple and can be achieved with an enum or something to that effect.

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

32 minutes ago, Apaec said:

If those still are the gold bracelet ids then i'm not sure what to suggest :/ Try using log statements to pinpoint exactly which line isn't working. Also, maybe position is the best way to determine this widget from its horizontal counterparts?

Just want to say I found out with the logger that the webwalking was giving errors. Adjusted my webwalking area and it's all working again. Could you give me an example of how I could use position instead of using root and child. I'm just starting and I can't seem to find an example online. 

Thanks for everything!

 

Link to comment
Share on other sites

 

1 hour ago, XaLeR said:

Is it possible with itemID?

 

50 minutes ago, Apaec said:

Also, maybe position is the best way to determine this widget from its horizontal counterparts? Using position would mean adding other bracelets in future would be simple and can be achieved with an enum or something to that effect.

 

@XaLeR Looks like maybe you could make use of the spell name field of the widget?

RS2Widget goldBraceletWidget = getWidgets().singleFilter(getWidgets().getAll(), w -> w.getSpellName().contains("Gold bracelet"));

 

Edited by Explv
Link to comment
Share on other sites

8 minutes ago, XaLeR said:

Just want to say I found out with the logger that the webwalking was giving errors. Adjusted my webwalking area and it's all working again. Could you give me an example of how I could use position instead of using root and child. I'm just starting and I can't seem to find an example online. 

Thanks for everything!

 

Sure, grab the widget with something like this:

Point widgetCoord = new Point(X,Y);
getWidgets().singleFilter(ROOT_ID, widget -> new Point(widget.getAbsX(), widget.getAbsY()).equals(widgetCoord));

You can store that point in an enum if you were to support different bracelets. Also, you will have to fill in the root id

Haven't tested that code as I wrote it in the reply box, but it should work. 

 

Glad the issue was solved!

3 minutes ago, Explv said:

 

 

 

@XaLeR Looks like maybe you could make use of the spell name field of the widget?


RS2Widget goldBraceletWidget = getWidgets().singleFilter(getWidgets().getAll(), w -> w.getSpellName().contains("Gold bracelet"));

 

Oo, I didn't spot that! looks promising.

Link to comment
Share on other sites

4 minutes ago, Explv said:

 

 

 

@XaLeR Looks like maybe you could make use of the spell name field of the widget?


RS2Widget goldBraceletWidget = getWidgets().singleFilter(getWidgets().getAll(), w -> w.getSpellName().contains("Gold bracelet"));

 

Yea I was trying that before I made this post. Probably it worked but the webwalking was broken so I thought to myself this doesn't work either :D It was stupid of me to not know there was a logger. I would've found the problem instantly.

Link to comment
Share on other sites

7 minutes ago, Apaec said:

Sure, grab the widget with something like this:


Point widgetCoord = new Point(X,Y);
getWidgets().singleFilter(ROOT_ID, widget -> new Point(widget.getAbsX(), widget.getAbsY()).equals(widgetCoord));

You can store that point in an enum if you were to support different bracelets. Also, you will have to fill in the root id

Haven't tested that code as I wrote it in the reply box, but it should work. 

 

Glad the issue was solved!

Oo, I didn't spot that! looks promising.

That seems easy enough. I'm gonna test it out.

Again thanks for everything!

  • Like 1
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...