Jump to content
mitsuki

trying to make my script eat while it is webwalking?

Recommended Posts

So to start with, here is me getting the dynamic skill level:

public int currentHP(int currentHealth){
        currentHealth = getSkills().getDynamic(Skill.forName("HITPOINTS"));
        return currentHealth;
    }

    int currentHealth = 0;

This is me creating a loop while it is webwalking so that it eats when health is 6 or below:

else if(downLadder.contains(myPlayer()) && !getInventory().isFull()){
            getWalking().webWalk(safeSpot);
            while(getWalking().webWalk(safeSpot)){
                if(currentHP(currentHealth) >= 6 && getInventory().contains("Trout")){
                    getInventory().interact("Trout", "Eat");
                }
            }
        }

 

It doesn't actually eat any food regardless of how much health my player has. Any idea where i'm going wrong?

Cheers in advance guys!

Link to post
Share on other sites

Try checking this out

 

WalkingEvent myEvent = new WalkingEvent(new Position(1, 2, 3)); //making the event
myEvent.setMinDistanceThreshold(0); 
myEvent.setEnergyThreshold(47);
myEvent.setBreakCondition(new Condition() {
    @Override
    public boolean evaluate() {
        return myPlayer().isUnderAttack();
    } //change to if health below x
});
execute(myEvent); //executing the event

 

 

  • Like 2
Link to post
Share on other sites

The webwalker will run it's own event and you will not be able to do any interactions as the script is not re-looping.

you can do what @skillerkidos1 suggested but you'll have to remember that you'll have to re-initiate the webwalk event

 

There are other ways around this if you decided to put in a ton of work :doge:

  • Like 1
Link to post
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.

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