August 22, 20205 yr 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"); } } }
August 22, 20205 yr 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
August 22, 20205 yr Author 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.
August 22, 20205 yr 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 August 22, 20205 yr by BravoTaco
August 22, 20205 yr 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 August 22, 20205 yr by OsPlay i put don't when is past, i didn't*
August 22, 20205 yr Author 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
August 22, 20205 yr 1 hour ago, Zunarb said: Thank you for pointing that out! After i fixed the variable timing it started working perfectly now Np.
Create an account or sign in to comment