Acerd Posted January 11, 2016 Share Posted January 11, 2016 (edited) public boolean isFletching() { boolean isFletching = false; Timer timer = new Timer(1800, null); while (timer.isRunning() && !isFletching) { isFletching = myPlayer().getAnimation() != -1 ? true : isFletching; } return isFletching; } public boolean isStringing() { boolean isStringing = false; Timer timer = new Timer(1200, null); while (timer.isRunning() && !isStringing) { isStringing = myPlayer().getAnimation() != -1 ? true : isStringing; } return isStringing; } These doesnt work can you tell me what im doing wrong?. Edited January 11, 2016 by Assnerd Quote Link to comment Share on other sites More sharing options...
IHB Posted January 11, 2016 Share Posted January 11, 2016 cant u do a while ur player is animating do nothing instead of timer OnLoop(){ If (!myPlayer().isAnimating()) { fletching knife 2 log shit } return(random(100,500); } somthng like tht Quote Link to comment Share on other sites More sharing options...
Acerd Posted January 11, 2016 Author Share Posted January 11, 2016 I can but its not reliable. Quote Link to comment Share on other sites More sharing options...
Joseph Posted January 11, 2016 Share Posted January 11, 2016 (edited) Don't use while loops in osbot please. Here's my secret. Create a timer. Set it to 0. Check the time passed. Before your fletching method. (Select knife and log). Do a animation check if true reset the timer. Then do a else if statements after. Check the timer and see if it passed like 4 secs. Then you would use your fletching method Edited January 11, 2016 by Joseph 1 Quote Link to comment Share on other sites More sharing options...
Mysteryy Posted January 11, 2016 Share Posted January 11, 2016 Why are you using a timer like this? There is much more solid logic that you could use here. 1 Quote Link to comment Share on other sites More sharing options...
ascentium Posted January 11, 2016 Share Posted January 11, 2016 Don't use while loops in osbot please. Here's my secret. Create a timer. Set it to 0. Check the time passed. Before your fletching method. (Select knife and log). Do a animation check if true reset the timer. Then do a else if statements after. Check the timer and see if it passed like 4 secs. Then you would use your fletching method Can I ask why while loops are bad? I understand that some may become infinite loops, is there another reason? Quote Link to comment Share on other sites More sharing options...
Acerd Posted January 11, 2016 Author Share Posted January 11, 2016 Don't use while loops in osbot please. Here's my secret. Create a timer. Set it to 0. Check the time passed. Before your fletching method. (Select knife and log). Do a animation check if true reset the timer. Then do a else if statements after. Check the timer and see if it passed like 4 secs. Then you would use your fletching method Could you give me an example (code) ? im still learning :E thanks in advance Quote Link to comment Share on other sites More sharing options...
Khaleesi Posted January 11, 2016 Share Posted January 11, 2016 (edited) Can I ask why while loops are bad? I understand that some may become infinite loops, is there another reason? You can use them, but make sure to properly break out of them. Getting a user stuck for 8 hours because a while loop didn't break properly is pretty annoying I didn't even use 1 while loop in all of my scripts Could you give me an example (code) ? im still learning :E thanks in advance Basicly this: (I'm using my own timer class though, not sure how osbots timer work) Timer animationTimer = new Timer(0); public void fletch(){ if (script.myPlayer().isAnimating()) animationTimer.reset(); if (animationTimer.getElapsed() > 2000) { //time between animations //start fletching }else{ //we are fletching } } Khaleesi Edited January 11, 2016 by Khaleesi 1 Quote Link to comment Share on other sites More sharing options...
Acerd Posted January 11, 2016 Author Share Posted January 11, 2016 (edited) You can use them, but make sure to properly break out of them. Getting a user stuck for 8 hours because a while loop didn't break properly is pretty annoying I didn't even use 1 while loop in all of my scripts Basicly this: (I'm using my own timer class though, not sure how osbots timer work) Timer animationTimer = new Timer(0); public void fletch(){ if (script.myPlayer().isAnimating()) animationTimer.reset(); if (animationTimer.getElapsed() > 2000) { //time between animations //start fletching }else{ //we are fletching } } Khaleesi thx Edited January 11, 2016 by Assnerd Quote Link to comment Share on other sites More sharing options...
MalikDz Posted January 11, 2016 Share Posted January 11, 2016 Don't use while loops in osbot please. Here's my secret. Create a timer. Set it to 0. Check the time passed. Before your fletching method. (Select knife and log). Do a animation check if true reset the timer. Then do a else if statements after. Check the timer and see if it passed like 4 secs. Then you would use your fletching method u made my day l0l 1 Quote Link to comment Share on other sites More sharing options...