Jump to content

Why is this code not working?


Lol_marcus

Recommended Posts

Hi, 

Is there any reason why it's not sipping a pot when my run energy goes below 30%? Ignore the fact that I only have a 4 dose on there, I'll use an array later to add all doses later.

public void drinkPots() throws InterruptedException	{

		if (settings.getRunEnergy() < 30) {
			getInventory().interact("Drink", "Energy potion(4)");
			sleep(random(50, 500));
					}
					new ConditionalSleep(4000, 200) {
					    @Override
					    public boolean condition() {
					        return (settings.getRunEnergy() > 90);
					    }
					}.sleep();
				  }

 

Link to comment
Share on other sites

With calling settings you are calling the variable itself with getSettings() you are calling a getter that may be doing more than just returning the variable itself. In most cases calling just settings will work but depending on when and where you are calling the settings variable it’s context could possibly not be the current bot context so it is unable to accurately retrieve the information needed while not throwing any errors. To verify this, print what the current value of that call is, to the console.

  • Like 2
Link to comment
Share on other sites

8 minutes ago, BravoTaco said:

With calling settings you are calling the variable itself with getSettings() you are calling a getter that may be doing more than just returning the variable itself. In most cases calling just settings will work but depending on when and where you are calling the settings variable it’s context could possibly not be the current bot context so it is unable to accurately retrieve the information needed while not throwing any errors. To verify this, print what the current value of that call is, to the console.

i knew that.. 

:troll:

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...