Jump to content

I need help with my code


Recommended Posts

Posted

I'm trying to make a script that changes the attack style by reaching a specific level of one skill so that it starts up another one.
Example: I'm going up Defense at level 30 when I reach level 30 I want it to change automatically because of the attack style to climb Attack

 

In the OSBot Logger the Message appears:

[INFO] [Bot # 1] [03/23 11:29:31 PM]: Defense is 30, attempting to switch attack styles

but does not change the style

 

Here my code:

Spoiler

 int defConfig = 0; //Not right config

        RS2Widget defence = getWidgets().get(548,47); //not the right widget ids, dont use this method btw, use filters
        if(getdefLevel () >= 25 && getConfigs().get(43) != defConfig){
            log ( "Defence is 30, attempting to switch attack styles" );
            if ( defence != null ) {
                if ( defence.isVisible () ) {
                    if ( defence.interact ( "change" ) ) {
                        log ( "Switched attack styles" );
                        }
                } else {
                    if ( getTabs ().open ( Tab.ATTACK ) ) {
                        log ( "Successfully opened attack tab" );
                        }
                }
            }
        }

 

 

Posted (edited)
1 hour ago, th3gos said:

Here my code

 

Does it at least switch tabs? If so your problem might be this line:

if ( defence.interact ( "change" ) ) {

There is no "change" interact option for that widget as far as I'm aware. The options are stuff like "Kick" or "Stab".  

Edit: I'm not fully sure as I have barely done any scripting and the docs aren't fully clear but you might be able to just use .interact(); without passing in a string to make it use the default interaction.

Edited by Theorems
  • Like 2

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