Jump to content
Frequently Asked Questions
  • Are you not able to open the client? Try following our getting started guide
  • Still not working? Try downloading and running JarFix
  • Help! My bot doesn't do anything! Enable fresh start in client settings and restart the client
  • How to purchase with PayPal/OSRS/Crypto gold? You can purchase vouchers from other users
  • Try asking for help in the chatbox
  • Need some advice on my written method.


    Cardozz
     Share

    Recommended Posts

    Hi there,

     

    I am kinda new to writing my own API / methods. I wrote a quick method which i want some advice on.

    public void hoverSkill(Skill skill){
    	if(!as.getTabs().isOpen(Tab.STATS)){
    		as.getTabs().open(Tab.STATS);
    	}
    		
    	if(as.getTabs().isOpen(Tab.STATS)){
    		// code move mouse to hover the skill set in the parameter.
    	}
    }
    

    The above method will require the parameter as a skill. I will later write the code for the mouse to hover over the set skill. However, i first want to check if the STATS tab is open, and normally i'd like to do this in a nested if-statement, but since the hoverSkill() method will only run once on request i had to seperate the check if the STATS tab is open or not (like i wrote above). Are there any other (better) ways to do this?

     

    I might be a little vague on my explanation, because i'm really over thinking this method while i'm writing this explanation lol.

     

    Thanks for any help in advance!

    Link to comment
    Share on other sites

    Just use an 

    } else {
    

    instead of checking the same condition twice

    he only wants to call the method once

     

    u can just do

    void hoverSkill(Skill skill){
    	if(getTabs().isOpen(Tab.STATS) || getTabs().open(Tab.STATS)) {
    		// insert stuff here
    	}
    }
    Link to comment
    Share on other sites


    void hoverSkill(Skill skill) {
    while (!getTabs().isOpen(Tab.STATS)) {
    getTabs().open(Tab.STATS);
    sleep(50);
    }
    //tabs is open, do whatever
    }
    Link to comment
    Share on other sites

        void hoverSkill(Skill skill) {
            while (!getTabs().isOpen(Tab.STATS)) {
                getTabs().open(Tab.STATS);
                sleep(50);
            }
            //tabs is open, do whatever
        }
    

    dreambot blocks for like everything besides walking

    Link to comment
    Share on other sites

     

    he only wants to call the method once

     

    u can just do

    void hoverSkill(Skill skill){
    	if(getTabs().isOpen(Tab.STATS) || getTabs().open(Tab.STATS)) {
    		// insert stuff here
    	}
    }

    Thats usefull.

     

    Yeah, the second check in my method is not necessary. :P

     

    What did you mean by "dreambot blocks for like everything besides walking" ?

    Link to comment
    Share on other sites

     

    What did you mean by "dreambot blocks for like everything besides walking" ?

     

    Meaning that the open method will not return until the client has finished opening the tab (or failed).

    Link to comment
    Share on other sites

    Meaning that the open method will not return until the client has finished opening the tab (or failed).

    The issue is if it lags the client will send the command and return that it managed to send the command but the window will not actually be open. Therefore it's never bad to sleepUntil it is definitely open.

    Link to comment
    Share on other sites

     Share

    ×
    ×
    • Create New...

    Important Information

    We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.