May 19, 20169 yr 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, 20169 yr by NewmansScripts
May 19, 20169 yr 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?
May 19, 20169 yr I've never run into this problem but, shouldn't paint update it whether or not it is in the onLoop?
May 19, 20169 yr 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, 20169 yr by liverare
May 19, 20169 yr Author 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, 20169 yr by NewmansScripts
Create an account or sign in to comment