Jump to content

Widget not working


Zunarb

Recommended Posts

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");
                    }
            }
            
        }
        

 

Link to comment
Share on other sites

10 minutes ago, Kramnik said:

Hi, you dont need to use widgets to cast spells. There is a Magic API :) https://osbot.org/api/org/osbot/rs07/api/Magic.html

The problem is not casting a spell, the problem is setting up a spell for autocast on a staff :)  Atleast i coudnt figure out any magic API that worked in the situation for me.

Link to comment
Share on other sites

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
Link to comment
Share on other sites

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*
Link to comment
Share on other sites

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 :) 

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