Jump to content

Stuck on ConditionalSleep


Lychees

Recommended Posts

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
Link to comment
Share on other sites

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
Link to comment
Share on other sites

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
Link to comment
Share on other sites

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

Link to comment
Share on other sites

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

                            }
                        }.sleep();

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

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