Jump to content

Performing actions while walking


poweruser321

Recommended Posts

if(myPlayer().isMoving()){
     //code
}

 

Thanks for the reply! but how do i use that with getWalking().webWalk()? I know I can't just stick it after getWalking().webWalk(destination) because it won't get read until after the walking is over. 

 

Sorry if this is a stupid question :I

Edited by poweruser321
Link to comment
Share on other sites

Thanks for the reply! but how do i use that with getWalking().webWalk()? I know I can't just stick it after getWalking().webWalk(destination) because it won't get read until after the walking is over. 

 

Sorry if this is a stupid question :I

if(myPlayer().isMoving()){
 // code to do while walking
} else {
   getWalking().webwalk(position);
}
Edited by GaetanoH
Link to comment
Share on other sites

if(myPlayer().isWalking()){
 // code to do while walking
} else {
   getWalking().webwalk(position);
}

 

From my understanding of this code, I don't think you're understanding quite what i want to do.

 

I want to drink potions while walking to the destination. 

 

My question still remains, how do i check if im moving (or do ANYTHING) while my player is moving towards his destination with webwalk?

Link to comment
Share on other sites

From my understanding of this code, I don't think you're understanding quite what i want to do.

 

I want to drink potions while walking to the destination. 

 

My question still remains, how do i check if im moving (or do ANYTHING) while my player is moving towards his destination with webwalk?

 

Just do an area check.

if(!DESTINATION_AREA.contains(myPlayer()&&myPlayer().isMoving())
{
//whatever you need
}

So as long as you're not in the destination area, you'll drink potions. Then you need some sort of timer or message listener so you don't spam drink potions.

 

Hopefully this is what you needed.

Edited by Twin
Link to comment
Share on other sites

From my understanding of this code, I don't think you're understanding quite what i want to do.

 

I want to drink potions while walking to the destination. 

 

My question still remains, how do i check if im moving (or do ANYTHING) while my player is moving towards his destination with webwalk?

 

As far as I know this is going to do some code when it's walking/ moving and will walk when it's not walking so I don't get you man :p

Link to comment
Share on other sites

From my understanding of this code, I don't think you're understanding quite what i want to do.

 

I want to drink potions while walking to the destination. 

 

My question still remains, how do i check if im moving (or do ANYTHING) while my player is moving towards his destination with webwalk?

Pseudo code:

walk to area
conditional sleep till player is moving
if player is moving && is not potted
drink potions
Link to comment
Share on other sites

As far as I know this is going to do some code when it's walking/ moving and will walk when it's not walking so I don't get you man :p

 

 

Just do an area check.

if(!DESTINATION_AREA.contains(myPlayer()&&myPlayer().isMoving())
{
//whatever you need
}

So as long as you're not in the destination area, you'll drink potions. Then you need some sort of timer or message listener so you don't spam drink potions.

 

Hopefully this is what you needed.

 

 

alright i must be too retarded to code. How can i even run the if statement while walking? everytime i use webWalk, it stops reading code until it reaches its destination. am i making sense or should i just uninstall my IDE?

 

 

 

Pseudo code:

walk to area
conditional sleep till player is moving
if player is moving && is not potted
drink potions

I still can't run any code/checks while walking. for example


        getWalking().webWalk(shop);
        new ConditionalSleep(2500, 100) {
        @Override
        public boolean condition() throws InterruptedException {
            return myPlayer().isMoving();
        }
    }.sleep();
    if(getInventory().contains(DSTAMINA_ID)){
        getInventory().getItem(DSTAMINA_ID).interact("Drop");
        Script.sleep(Script.random(600, 800));
        log("vial dropped");
    }else{log("nothing to drop");} 

will only read past the webwalking line once the player is already completely finished walking. is this making any sense or am i actually retarded?

Edited by poweruser321
Link to comment
Share on other sites

alright i must be too retarded to code. How can i even run the if statement while walking? everytime i use webWalk, it stops reading code until it reaches its destination. am i making sense or should i just uninstall my IDE?

 

 

I still can't run any code/checks while walking. for example


        getWalking().webWalk(shop);
        new ConditionalSleep(2500, 100) {
        @Override
        public boolean condition() throws InterruptedException {
            return myPlayer().isMoving();
        }
    }.sleep();
    if(getInventory().contains(DSTAMINA_ID)){
        getInventory().getItem(DSTAMINA_ID).interact("Drop");
        Script.sleep(Script.random(600, 800));
        log("vial dropped");
    }else{log("nothing to drop");} 

will only read past the webwalking line once the player is already completely finished walking. is this making any sense or am i actually retarded?

No, you're not retarded. It will walk until it reaches the final destination. However, you could make a condition for when to walk to next position and you'll be able to control what to do while the player is walking.

if player is not moving || distance between player and current destination < 6
webwalk to position
else
do pot stuff
Link to comment
Share on other sites

 

No, you're not retarded. It will walk until it reaches the final destination. However, you could make a condition for when to walk to next position and you'll be able to control what to do while the player is walking.

if player is not moving || distance between player and current destination < 6
webwalk to position
else
do pot stuff

 

 

From my understanding of what youre saying it seems ill have to break up the path into sections instead of just telling it to walk to a single area.   

 

I feel like this will check to see if im moving/far enough away, then walk to the final destination. I dont see how i can run any code between when it starts and ends the webwalking to position. The "if condition" if only checked once, before the "webwalk to position." Then once the webwalking starts it will continue until the end. im still not seeing how this solves the problem of " It will walk until it reaches the final destination. "

 

 

Sorry if this is dumb but i cant tell you how shitty i feel that i cant get any of the 3 responses to this thread to work. I thought the question was clear so I just feel completely inept right now

Link to comment
Share on other sites

I dont get how so many people did not understand what you want to do.

 

What you are looking for is the webwalking event. I'm not too familiar with their use, but i think you need to create your own, override the execute method (do your drinking there and then return super.execute()) and then use script.execute() to run it.

 

Code could look like this (did not test it though):

WebWalkEvent event = new WebWalkEvent(routeFinder, position){
                @Override
		public int execute() 
                {
                        // do your drinking logic here
                        return super.execute();
		}
	});

	script.execute(event);
Edited by anderiel
  • Like 1
Link to comment
Share on other sites

 

I dont get how so many people did not understand what you want to do.

 

What you are looking for is the webwalking event. I'm not too familiar with their use, but i think you need to create your own, override the execute method (do your drinking there and then return super.execute()) and then use script.execute() to run it.

 

Code could look like this (did not test it though):

WebWalkEvent event = new WebWalkEvent(routeFinder, position){
                @Override
		public int execute() 
                {
                        // do your drinking logic here
                        return super.execute();
		}
	});

	script.execute(event);

 

Thanks for the response! much appreciated. this looks like the kind of thing i was looking for, ill mess around with it later today when i have time and report back

Link to comment
Share on other sites

alright i must be too retarded to code. How can i even run the if statement while walking? everytime i use webWalk, it stops reading code until it reaches its destination. am i making sense or should i just uninstall my IDE?

 

 

I still can't run any code/checks while walking. for example


        getWalking().webWalk(shop);
        new ConditionalSleep(2500, 100) {
        @Override
        public boolean condition() throws InterruptedException {
            return myPlayer().isMoving();
        }
    }.sleep();
    if(getInventory().contains(DSTAMINA_ID)){
        getInventory().getItem(DSTAMINA_ID).interact("Drop");
        Script.sleep(Script.random(600, 800));
        log("vial dropped");
    }else{log("nothing to drop");} 

will only read past the webwalking line once the player is already completely finished walking. is this making any sense or am i actually retarded?

 

I thought they made webwalking check for conditions? I haven't used anything where I would need to do that, so I haven't really tested it. Maybe I misread something when webwalking was released, so sorry about that.

Link to comment
Share on other sites

I was wondering if there is a way to perform actions (specifically drinking a potion) while walking?   can it be done with webwalk() or is another walking method required (if possible at all)? 

 

 

I thought they made webwalking check for conditions? I haven't used anything where I would need to do that, so I haven't really tested it. Maybe I misread something when webwalking was released, so sorry about that.

 

What you need to do is to create your own WebWalkEvent and set a break condition so that it will stop executing the walking code when you need to drink a potion:

final WebWalkEvent webWalkEvent = new WebWalkEvent(area);
webWalkEvent.setBreakCondition(new Condition() {
    @Override
    public boolean evaluate() {
        return needToDrinkPotion(); 
    }
});
execute(webWalkEvent);
  • Like 3
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...