Jump to content

Why is this code not working?


Recommended Posts

Posted

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();
				  }

 

Posted

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
Posted
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:

Posted (edited)
On 5/25/2020 at 5:32 PM, Lol_marcus said:

I'll use an array later to add all doses later.

This is not related to your actual question, just a suggestion:

Try using a Filter<Item> to grab all the energy pots at various doses, if you haven't already

Edited by Ace99

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