Jump to content

Script not doing anything after webwalk, or until paused / resumed


Satan

Recommended Posts

Hi all,

I'm working on a script.

There are no errors in my script and no error messages appear, This is not the first script I have made and I like to believe I have a decent amount of scripting knowledge. 

For some reason, the script just likes to sit still after having webwalked to the bank / field. Not doing anything, not logging anything even though I have a log messages troughout my whole script, also in the beginning of the onloop and before calling the actual methods.

The weird thing is if I pause and then resume the script it will run as expected. (for a couple of trips) And sometimes runs fine for like ~10 trips.

import org.osbot.rs07.api.map.Area;
import org.osbot.rs07.api.map.constants.Banks;
import org.osbot.rs07.api.model.Entity;
import org.osbot.rs07.event.WebWalkEvent;
import org.osbot.rs07.script.Script;
import org.osbot.rs07.script.ScriptManifest;
import org.osbot.rs07.utility.Condition;
import org.osbot.rs07.utility.ConditionalSleep;

@ScriptManifest(author = "contiez", info = "Farms", logo = "", name = "potato", version = 1.0)

public class potato extends Script {

	private int itemid = 1942;
	private int world = 0;

	@Override
	public int onLoop() throws InterruptedException {
		log("Loop");
		getPotatos();
		return (random(400, 600));
	}

	private void getPotatos() throws InterruptedException {
		log("method 1");
		
		Area field = new Area(3155, 3290, 3140, 3268);
		Area pregate = new Area(3143, 3292, 3146, 3294);
		Entity potato = objects.closest("Potato");

		if (world == 0) {
			world = worlds.getCurrentWorld();
		}

		if (!getInventory().isFull()) {
			if (!field.contains(myPlayer())) {
				log("walk to field");
				WebWalkEvent webEvent = new WebWalkEvent(field);
				webEvent.setBreakCondition(new Condition() {
					@Override
					public boolean evaluate() {
						return field.contains(myPlayer());
					}
				});
				execute(webEvent);
			} else if (field.contains(myPlayer()) && getMap().canReach(potato)) {
				if (potato != null)
					potato.interact("Pick");
				new ConditionalSleep(750, 500) {
					@Override
					public boolean condition() throws InterruptedException {
						return myPlayer().isAnimating() && myPlayer().isMoving();
					}
				}.sleep();
			} else if (field.contains(myPlayer()) && !getMap().canReach(potato)) {
				log("walk to gate");
				WebWalkEvent webEvent = new WebWalkEvent(pregate);
				webEvent.setBreakCondition(new Condition() {
					@Override
					public boolean evaluate() {
						return pregate.contains(myPlayer());
					}
				});
				execute(webEvent);
			}
		} else if (getInventory().isFull()) {
			bank();
		}

	}

	private void bank() throws InterruptedException {
		if (Banks.DRAYNOR.contains(myPlayer())) {
			if (getBank().isOpen()) {
				getBank().depositAll();
			} else {
				getBank().open();
			}
		} else {
			WebWalkEvent webEvent = new WebWalkEvent(Banks.DRAYNOR);
			log("walk to bank");
			webEvent.setBreakCondition(new Condition() {
				@Override
				public boolean evaluate() {
					return Banks.DRAYNOR.contains(myPlayer());
				}
			});
			execute(webEvent);
		}
	}

}

Help would be really appreciated!

Edited by Satan
Link to comment
Share on other sites

14 minutes ago, Neanel said:

Place a log after "execute(webEvent)" & see if it ever gets there, if it does you know the problem is indeed with webwalking, when do you exactly call this function?
If it's not, place logs throughout the script & see which one shows up last to know where exactly it failed.

Hey, thanks for replying. It always gets to where it needs to be, and logs: "WebWalkingEvent; Terminated because of break condition!" in the console. weirdly enough that is also the last method being called before it stops and just stands there. Even after restarting the script it does not seem to do anything now, where as before it did. Note that i didnt change anything in the script.

Link to comment
Share on other sites

5 minutes ago, Neanel said:

Are you checking if the player is already in the area before calling the webwalk event? Otherwise it would just be stuck in a loop.

if suddenly you’re script isn’t doing anything you might wanna reinstall everything & check if there are no nullpointers when assigning a value to a variable.

Thanks again, but yes I do checks before calling any method and there are null checks troughout the script, also if there were to be a NPE it would log it to the console i believe.

Link to comment
Share on other sites

5 minutes ago, Token said:

Always add an else case at the end and print an error message in there, it's most likely a logical problem where none of your conditions are met

Thanks for replying! Except how would this explain the log message at the top of the onLoop() not printing? It is not inside another block or anything.

Link to comment
Share on other sites

30 minutes ago, Satan said:

Thanks for replying! Except how would this explain the log message at the top of the onLoop() not printing? It is not inside another block or anything.

I don't see any onLoop in there nor the code running after webwalking so I can't provide any info on that

Link to comment
Share on other sites

On 6/6/2019 at 2:25 PM, Token said:

I don't see any onLoop in there nor the code running after webwalking so I can't provide any info on that

 

On 6/6/2019 at 4:21 PM, Neanel said:

So could you post the log output? Then it'll be clearer what the problem is

I put the full code in the OP now. Did change what the script collects but the banking and walking is identical. Hopefully y'all can help.

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