NewmansScripts Posted May 19, 2016 Share Posted May 19, 2016 (edited) Hello. I am making a on screen GUI (paint) for my script and currently have all my code in the onPaint() method. The issue is my counter (in onLoop) occurs in a while loop and so the paint does not get updated until the while loop ends. Is there a way to call onPaint() in the while loop? The Client.onPaint() says it is depreciated. Thanks! Edited May 19, 2016 by NewmansScripts Quote Link to comment Share on other sites More sharing options...
Terminus Posted May 19, 2016 Share Posted May 19, 2016 why arent you making the GUI in swing? Quote Link to comment Share on other sites More sharing options...
liverare Posted May 19, 2016 Share Posted May 19, 2016 You should avoid using while loops, because poorly coded ones can result in an infinite loop. You'd have to show us your code before we can get a better understanding of your problem. Where exactly did you place the while loop? Quote Link to comment Share on other sites More sharing options...
Qubit Posted May 19, 2016 Share Posted May 19, 2016 I've never run into this problem but, shouldn't paint update it whether or not it is in the onLoop? Quote Link to comment Share on other sites More sharing options...
liverare Posted May 19, 2016 Share Posted May 19, 2016 (edited) I've never run into this problem but, shouldn't paint update it whether or not it is in the onLoop? Yes, the onPaint runs independently from the onLoop. However, if some while loop is preventing the updating of a variable--which the onPaint is calling--then the variable won't change. int count = 0; @Override public int onLoop() throws InterruptedException { count = 0; while (SOME_CONDITION_SOON_TO_END) { ... } count++; return 100; } @Override public void onPaint(Graphics2D g) { g.drawString("Count: " + count, 25, 25); } The counter is being updated AFTER the loop. The onPaint doesn't receive a new value until then. Edited May 19, 2016 by liverare Quote Link to comment Share on other sites More sharing options...
czpy Posted May 19, 2016 Share Posted May 19, 2016 I honestly don't got it Quote Link to comment Share on other sites More sharing options...
NewmansScripts Posted May 19, 2016 Author Share Posted May 19, 2016 (edited) Sorry my mistake. The counter is being updated in onMessage() shown here: public void onMessage(Message message) throws java.lang.InterruptedException { String txt = message.getMessage().toLowerCase(); if (txt.contains("you hammer")) { barsDone++; } } There is a while statement in my while loop that check for the animation which as print the message that I am looking for. Fixed the issue. Did away with my while loop. Seems like that was causing the issue Edited May 19, 2016 by NewmansScripts Quote Link to comment Share on other sites More sharing options...