Jump to content

Widget not working


Recommended Posts

Posted

Okay so what am i doing wrong here? It opens up the tab to choose the spell but it does not pick the fire bolt based on its widget. It keeps thinking that fire bolt is null even tho the tab for it is open? Trying to setup it up to autocast for a staff.

        

public void attackStyle() throws InterruptedException {
            RS2Widget fireBolt = getWidgets().get(201,1,8);
            RS2Widget spellChoise = getWidgets().get(593,28);
            
            if (getSkills().getDynamic(Skill.MAGIC) >= 35) {
                   getTabs().open(Tab.ATTACK);
                    sleep(1000);
                    spellChoise.interact("Choose spell");
                    sleep(1000);
                    if (fireBolt != null) {
                        log("Selecting fire bolt");
                    fireBolt.interact("Fire Bolt");
                    }
            }
            
        }
        

 

Posted (edited)
RS2Widget fireBolt = getWidgets().get(201,1,8);
            RS2Widget spellChoise = getWidgets().get(593,28);
            
            if (getSkills().getDynamic(Skill.MAGIC) >= 35) {
                   getTabs().open(Tab.ATTACK);

What appears to be happening is that you are setting the variable too soon. You set it before opening the tab, when you to set it after you have verified that the tab is open.

Edited by BravoTaco
Posted (edited)

I'm not an expert, i didn't test it, but i supouse that i'll do like:

 

public void attackStyle() throws InterruptedException {

        if (getSkills().getDynamic(Skill.MAGIC) >= 35) {
            // open the tab...
            getTabs().open(Tab.ATTACK);
            
            // wait until tab is open...
            new ConditionalSleep(5000){
                @Override
                public boolean condition() throws InterruptedException {
                    if(getWidgets().isVisible(593,28)) return true;
                    return getTabs().isOpen(Tab.ATTACK);
                }
            }.sleep();
            
            // failed to see widget?
            if(!getWidgets().isVisible(593,28)) return;
            
            // take the widget.
            RS2Widget spellChoise = getWidgets().get(593,28);
            
            // interact with the widget.
            spellChoise.interact("Choose spell");
            
            // sleep until can see the widget.
            new ConditionalSleep(5000){

                @Override
                public boolean condition() throws InterruptedException {
                    return getWidgets().isVisible(201,1,8);
                }
            }.sleep();
            
            // failed to see widget?
            if(!getWidgets().isVisible(201,1,8)) return;
            
            // take the widget.
            RS2Widget fireBolt = getWidgets().get(201,1,8);
            
            if (fireBolt != null) {
                log("Selecting fire bolt");
                fireBolt.interact("Fire Bolt");
            }
        }

 

Edited by OsPlay
i put don't when is past, i didn't*
Posted
29 minutes ago, BravoTaco said:

RS2Widget fireBolt = getWidgets().get(201,1,8);
            RS2Widget spellChoise = getWidgets().get(593,28);
            
            if (getSkills().getDynamic(Skill.MAGIC) >= 35) {
                   getTabs().open(Tab.ATTACK);

What appears to be happening is that you are setting the variable too soon. You set it before opening the tab, when you to set it after you have verified that the tab is open.

Thank you for pointing that out! After i fixed the variable timing it started working perfectly now :) 

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