Jump to content
View in the app

A better way to browse. Learn more.

OSBot :: 2007 OSRS Botting

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Running Loop Once then Nothing.

Featured Replies

public int onLoop() throws InterruptedException {
		for (Node n : nodes) {
			if (n.validate()) {
				n.execute();
			}
		}
		return 200;
	}
	

When I run this, it checks validate and then executes, but after it has finished executing it just stands there?

public int onLoop() throws InterruptedException {
		for (Node n : nodes) {
			if (n.validate()) {
				n.execute();
			}
		}
		return 200;
	}
	

When I run this, it checks validate and then executes, but after it has finished executing it just stands there?

 

 

 

how many nodes do you have, and can we see see your validate() statements? also are you sure its not continuously looping in your execute() methods?

  • Author

how many nodes do you have, and can we see see your validate() statements? also are you sure its not continuously looping in your execute() methods?

 

Just one node.

	public boolean validate() throws InterruptedException {
		return tree != null && tree.hasAction("Chop down") && !sA.myPlayer().isAnimating() &&
				!sA.inventory.isFull();

Edited by Expels

 

Just one node.

	public boolean validate() throws InterruptedException {
		return tree != null && tree.hasAction("Chop down") && !sA.myPlayer().isAnimating() &&
				!sA.inventory.isFull();

 

you shouldnt be using a node format for just 1 node. regardless, does it chop 1 tree then just stop working?

  • Author

you shouldnt be using a node format for just 1 node. regardless, does it chop 1 tree then just stop working?

 

I have added dropping as well, but yes I chops once and then just stands around.

 

Just one node.

	public boolean validate() throws InterruptedException {
		return tree != null && tree.hasAction("Chop down") && !sA.myPlayer().isAnimating() &&
				!sA.inventory.isFull();

Why not just return one thing such as the inventory not being full and make it simpler instead of accessing a unnecessary tree variable you created when you don' t need it.

 

e.g for Chop

 

return !sA.getInventory().isFull();

 

for Drop

 

return sA.getInventory().isFull();

 

May or may not fix your problem but you don't need to null check something in your validate unless you were planning on doing something like this which I have in my BDK/Gwd 

 

(S.getGroundItems().closest(gi -> S.AREA_DRAGONS.contains(gi) && lootList.contains(gi.getName()) && S.getMap().canReach(gi)) != null);

 

Also im assuming your node framework was taken from Booch's tutorial right?

  • Author

Why not just return one thing such as the inventory not being full and make it simpler instead of accessing a unnecessary tree variable you created when you don' t need it.

 

e.g for Chop

 

return !sA.getInventory().isFull();

 

for Drop

 

return sA.getInventory().isFull();

 

May or may not fix your problem but you don't need to null check something in your validate unless you were planning on doing something like this which I have in my BDK/Gwd 

(S.getGroundItems().closest(gi -> S.AREA_DRAGONS.contains(gi) && lootList.contains(gi.getName()) && S.getMap().canReach(gi)) != null);

Also im assuming your node framework was taken from Booch's tutorial right?

 

If I just check if Inventory is full then it will just spam click. Doing it that way doesn't work anyway.

 

And yes.

If I just check if Inventory is full then it will just spam click. Doing it that way doesn't work anyway.

 

And yes.

You do know validate only toggles the class to activate.

 

If it spams click that's you're interaction code :/

 

To fix 'spam clicks' use cond sleeps and checks i.e

 

long logCount =  getInventory().getAmount("Name of log"); 

 

and let's say ur interacting with a tree for eg

 

if(tree.interact("Chop down")) {

 

cond sleep(7500) 

 

return getInventory().getAmount("Name of log") > logCount;

 

that should fix spam clicks tbh

  • Author

You do know validate only toggles the class to activate.

 

If it spams click that's you're interaction code :/

 

To fix 'spam clicks' use cond sleeps and checks i.e

 

long logCount =  getInventory().getAmount("Name of log"); 

 

and let's say ur interacting with a tree for eg

 

if(tree.interact("Chop down")) {

 

cond sleep(7500) 

 

return getInventory().getAmount("Name of log") > logCount;

 

that should fix spam clicks tbh

 

It would fix the spam clicking but it still doesn't loop it just stands there after chopping down the tree, there are no errors and the script doesn't stop, so I'm not really sure what is causing it.

It would fix the spam clicking but it still doesn't loop it just stands there after chopping down the tree, there are no errors and the script doesn't stop, so I'm not really sure what is causing it.

Are you still using that tree variable at the top of your class?

 

Could you share more code? It'd really help 

 

Your full chop class and ur main class preferably 

  • Author

Are you still using that tree variable at the top of your class?

 

Could you share more code? It'd really help 

 

Your full chop class and ur main class preferably 

private List<Node> nodes = new ArrayList<Node>();

	@[member=Override]
	public void onStart() {
		Collections.addAll(nodes, 
				new Chopping(this));
	}
	
	
	@[member=Override]
	public int onLoop() throws InterruptedException {
		for (Node n : nodes) {
			if (n.validate()) {
				n.execute();
				break;
			}
		}
		return 200;
	}
Constants c = new Constants();
	RS2Object tree = sA.objects.closest("Tree");
	
	public Chopping(Script sA) {
		super(sA);
		// TODO Auto-generated constructor stub
	}

	@[member=Override]
	public boolean validate() throws InterruptedException {
		return !sA.inventory.isFull();
		
	}

	@[member=Override]
	public int execute() {
		if (tree != null) {
			tree.interact("Chop down");
			new ConditionalSleep(1000, 4000) {
				
				@[member=Override]
				public boolean condition() throws InterruptedException {
					// TODO Auto-generated method stub
					return !sA.myPlayer().isAnimating();
				}
			}.sleep();
		} else {
			sA.camera.toEntity(tree);
		}
		return 200;
	}

}
private List<Node> nodes = new ArrayList<Node>();

	@[member='Override']
	public void onStart() {
		Collections.addAll(nodes, 
				new Chopping(this));
	}
	
	
	@[member='Override']
	public int onLoop() throws InterruptedException {
		for (Node n : nodes) {
			if (n.validate()) {
				n.execute();
				break;
			}
		}
		return 200;
	}
Constants c = new Constants();
	RS2Object tree = sA.objects.closest("Tree");
	
	public Chopping(Script sA) {
		super(sA);
		// TODO Auto-generated constructor stub
	}

	@[member='Override']
	public boolean validate() throws InterruptedException {
		return !sA.inventory.isFull();
		
	}

	@[member='Override']
	public int execute() {
tree = sA.objects.closest("Tree");
		if (tree != null) {
			tree.interact("Chop down");
			new ConditionalSleep(1000, 4000) {
				
				@[member='Override']
				public boolean condition() throws InterruptedException {
					// TODO Auto-generated method stub
					return !sA.myPlayer().isAnimating();
				}
			}.sleep();
		} else {
			sA.camera.toEntity(tree);
		}
		return 200;
	}

}

 

you only call "tree = sA.objects.closest("Tree");" once when you make an instance of the class.

id recommend adding it into the execute method as the first line as above. also, id make it a local variable instead of global.

you only call "tree = sA.objects.closest("Tree");" once when you make an instance of the class.

id recommend adding it into the execute method as the first line as above. also, id make it a local variable instead of global.

What i was literally going to say :P

  • Author

you only call "tree = sA.objects.closest("Tree");" once when you make an instance of the class.

id recommend adding it into the execute method as the first line as above. also, id make it a local variable instead of global.

 

Now it works. Thank you!

Create an account or sign in to comment

Recently Browsing 0

  • No registered users viewing this page.

Account

Navigation

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.