Jump to content

Stuck on ConditionalSleep


Recommended Posts

Posted (edited)

Hello guys,

Im trying to get back into scripting and my first project is a pizza base maker but im trying to add conditionalSleep

but i can get it to work.

if (new ConditionalSleep(1200)
            {
              public boolean condition()
                throws InterruptedException
              {
                return Main.this.myPlayer().isAnimating();
              }
            }.sleep()) {
            }
          }

The problem is when i make a pizza base my player isnt Animating.

(this.inventory.getAmount(new String[] { "Pizza base" }) == 9)

Ive also treid to work with the amount in inventory but still cant figure it out.

some help would be great ;)
 

Edited by Lychees
Posted
16 minutes ago, Lychees said:

Hello guys,

Im trying to get back into scripting and my first project is a pizza base maker but im trying to add conditionalSleep

but i can get it to work.


if (new ConditionalSleep(1200)
            {
              public boolean condition()
                throws InterruptedException
              {
                return Main.this.myPlayer().isAnimating();
              }
            }.sleep()) {
            }
          }

The problem is when i make a pizza base my player isnt Animating.


(this.inventory.getAmount(new String[] { "Pizza base" }) == 9)

Ive also treid to work with the amount in inventory but still cant figure it out.

some help would be great ;)
 

If there's an animation but it isn't constant you can make use of timers, I believe Juggles has a snippet in the snippet section. If there's not an animation, you can make use of the inventory.

  • Like 1
Posted
21 minutes ago, HunterRS said:

the conditional sleep should not be inside the if, it should accure if the if statement is true.

Example:


if(getBank().depositAll()){
						new ConditionalSleep(2000) {
							@Override
							public boolean condition() {
								return getInventory().isEmpty();
							}
						}.sleep();
					}

 

Why shouldn't the conditional sleep be inside the if? ConditionalSleep#sleep returns a boolean (relating to the success), and as such can be used for conditional/ternary expressions.

@Lychees You need to find some other way to check this! Perhaps implement some kind of inventory listener of your own design, or have a concurrent timer counting the time since a pizza base was last made?

-Apa

  • Like 1
Posted
23 minutes ago, Apaec said:

Why shouldn't the conditional sleep be inside the if? ConditionalSleep#sleep returns a boolean (relating to the success), and as such can be used for conditional/ternary expressions.

@Lychees You need to find some other way to check this! Perhaps implement some kind of inventory listener of your own design, or have a concurrent timer counting the time since a pizza base was last made?

-Apa

*facepalm*, You are right, I should go to sleep Lol

Posted

                        new ConditionalSleep(25000, 4000) {
                            @Override
                            public boolean condition() throws InterruptedException {
                                return !getInventory().contains("Pot of flour", "Jug of water")
                                        || getDialogues().inDialogue();

                            }
                        }.sleep();

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...