Cardozz 46 Share Posted June 9, 2016 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 More sharing options...
Before 96 Share Posted June 9, 2016 I always do it like that. Link to comment Share on other sites More sharing options...
Mad 86 Share Posted June 9, 2016 Just use an } else { instead of checking the same condition twice Link to comment Share on other sites More sharing options...
Rabrg 83 Share Posted June 9, 2016 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 More sharing options...
Mad 86 Share Posted June 9, 2016 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 More sharing options...
Rabrg 83 Share Posted June 9, 2016 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 More sharing options...
Mad 86 Share Posted June 9, 2016 dreambot blocks for like everything besides walking oh it does? that seems weird Link to comment Share on other sites More sharing options...
Cardozz 46 Author Share Posted June 9, 2016 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. What did you mean by "dreambot blocks for like everything besides walking" ? Link to comment Share on other sites More sharing options...
Santa 2 Share Posted June 10, 2016 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 More sharing options...
Hopewelljnj 46 Share Posted June 11, 2016 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 More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.