Jump to content

Widgets Issue


Recommended Posts

Posted (edited)

Hello guys, I'm trying to make a Al-Kharid Smelting bars script.

 

One problem that I am having is that my script won't use the widgets. 

 

RS2Widget bronze = getWidgets().get(311, 4);

if (bronze != null){
                        bronze.interact("Smelt X Bronze");
                        getKeyboard().typeString("" + (int)((Math.random()*99) + 30));
                    }

I also tried RS2Widget bronze = getWidgets().getWidgetContainingText("Bronze") which also doesn't work.

How come this code doesn't work?

The code before this interacts with the furnace then the bar options pop up and then the script does nothing.

 

Image: http://imgur.com/IYd0exp

 

Edited by ElloPOPz
Posted

Nope does not work

Here's my code for the widget:
 

RS2Widget bronze = getWidgets().getWidgetContainingText("Bronze");

furnace.interact("Smelt");
                    if (bronze != null){
                        bronze.interact("Smelt X");

                    }

Posted

It doesn't work still

 

Here's my code for traveling from bank to smelting place and smelting the bars

 

RS2Object furnace = objects.closest("Furnace");
        RS2Object bank = objects.closest("Bank booth");
        RS2Widget bronze = getWidgets().getWidgetContainingText("Bronze");
        final Area FURNACE_AREA = new Area(3274, 3184, 3279, 3188);
        final Area BANK_AREA = new Area(3269, 3166, 3271, 3169);
        
            if (!FURNACE_AREA.contains(myPlayer())){
                getWalking().walk(FURNACE_AREA.getRandomPosition());
                if (!myPlayer().isAnimating()){
                    if (bronze != null){
                        bronze.interact("Smelt X");
                        getKeyboard().typeString("" + (int)((Math.random()*99) + 30));
                    } else
                        furnace.interact("Smelt");
                }
            }

Posted (edited)

your logic is really bad :E

there's a check if player is not in furnace area and there's an interact with furnace in there too.

RS2Object furnace = objects.closest("Furnace");
        RS2Object bank = objects.closest("Bank booth");
        RS2Widget bronze = getWidgets().getWidgetContainingText("Bronze");
        final Area FURNACE_AREA = new Area(3274, 3184, 3279, 3188);
        final Area BANK_AREA = new Area(3269, 3166, 3271, 3169);
        
            if (!FURNACE_AREA.contains(myPlayer())) {
                getWalking().walk(FURNACE_AREA.getRandomPosition());
               } else {
                    if (bronze != null) {
                        bronze.interact("Smelt X");
                        sleep(1250);
                        getKeyboard().typeString("" + (int)((Math.random()*99) + 30));
                        new ConditionalSleep(150_000) {
                        @Override
                         public boolean condition() throws InterruptedException {
                           return !getInventory().contains("Tin ore");
                            }
                         }.sleep();
                      } else {
                        furnace.interact("Smelt");
                         new ConditionalSleep(5_000) {
                        @Override
                       public boolean condition() throws InterruptedException {
                         return bronze != null;
                     }
                 }.sleep();
                }
            }
Edited by Acerd
Posted

Yeah... this is my first script I'm writing. Trying to learn how to script ;)

btw these errors pop up

 

ConditionalSleep cannot be resolved to a type

 

the method condition() of  type new ConditionSleep(){} must override or implement a supertype method

 

What do they mean?

 

Thanks for helping

Posted

Yeah... this is my first script I'm writing. Trying to learn how to script wink.png

btw these errors pop up

 

ConditionalSleep cannot be resolved to a type

 

the method condition() of  type new ConditionSleep(){} must override or implement a supertype method

 

What do they mean?

 

Thanks for helping

import conditionalSleep

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

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