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.

What do i do wrong?

Featured Replies

Hi Osbot scripters!

 

I have been f*cking around with this all morning. I have no idea what i'm doing wrong. removing the } else { wont work either.. Oaks and Willows are working. Yews are not..

 

EDIT: Tried Else if statements. Didn't work either. 

		case CHOP:
			Entity Yew = objects.closest("Yew");
			Entity Willow = objects.closest("Willow");
			Entity Oak = objects.closest("Oak");
			if (Willow != null) {
				if (Willow.isVisible()) {
					Willow.interact("Chop down");
				} else {
					sleep(random(500, 700));
				}
			} else if (Oak != null) {
				if (Oak.isVisible()) {
					Oak.interact("Chop down");
				} else {
					sleep(random(500, 700));
				}
			} else if (Yew != null) {
				if (Yew.isVisible()) {
					Yew.interact("Chop down");
				} else {
					sleep(random(500, 700));
				}
			}
		case CHOP:
			Entity Willow = objects.closest("Willow");
			if (Willow != null) {
				if (Willow.isVisible()) {
					Willow.interact("Chop down");
				} else {
					sleep(random(500, 700));
				} 
				} else {
				Entity Oak = objects.closest("Oak");
				if (Oak != null) {
					if (Oak.isVisible()) {
						Oak.interact("Chop down");
					} else {
						sleep(random(500, 700));
					}
				} else {
					Entity Yew = objects.closest("Yew");
					if (Yew != null) {
						if (Yew.isVisible()) {
							Yew.interact("Chop down");
						} else {
							sleep(random(500, 700));
						}
					}
				}
			}

Edited by OSRS Sebastian

Have you tried adding logs 
 

log("Can I reach this statement?");

and also what does your getState look like?

 

 

You should also look into the InteractionEvent API. it handles visibility checks etc. Real easy to use

 

http://osbot.org/api/org/osbot/rs07/event/InteractionEvent.html

 

EXAMPLE SNIPPET:

public boolean interact(final Entity entity, final String option) {
InteractionEvent IE = new InteractionEvent(entity, option);
 IE.setOperateCamera(false);
 IE.setWalkTo(false);
 IE.setHover(true);
    if(IE != null) {
	execute(IE);
         //other checks 
    }
}

//
if (interact(tree,"Chop")) 
///

Edited by Trinity

  • Author

Have you tried adding logs 

 

log("Can I reach this statement?");

and also what does your getState look like?

 

 

You should also look into the InteractionEvent API. it handles visibility checks etc. Real easy to use

 

I will look into interactionEvent. But i find it very difficult to understand the api somehow.. 

	private State getState() {
		Entity treeE = objects.closest(tree);
		if (inventory.isFull())
			return State.BANK;
		if (treeE != null && treeE.isVisible())
			if (!myPlayer().isAnimating())
				return State.CHOP;
		return State.WAIT;
	}

	private enum State {
		CHOP, WAIT, BANK, // DROP
	};

 

I will look into interactionEvent. But i find it very difficult to understand the api somehow.. 

	private State getState() {
		Entity treeE = objects.closest(tree);
		if (inventory.isFull())
			return State.BANK;
		if (treeE != null && treeE.isVisible())
			if (!myPlayer().isAnimating())
				return State.CHOP;
		return State.WAIT;
	}

	private enum State {
		CHOP, WAIT, BANK, // DROP
	};

 

Looks okay to me. You said it works for 2 trees? Can you throw in some log statements inside the case and run it for me?

  • Author

Looks okay to me. You said it works for 2 trees? Can you throw in some log statements inside the case and run it for me?

 

Will do. Just put some logs in every case? Like: "Going to bank", "Chopping willows" bla bla?

Yes or just in the Chop case between each tree

Edited by Trinity

  • Author

Yes or just in the Chop case between each tree

 

Have set a log for every tree type. Willow and Oak logs perfectly. But the Yew log doesn't show up.. so i'm guessing it doesn't read that peace of code..

[INFO][Bot #1][11/30 02:09:51 PM]: Started script : SBWoodcutter
[INFO][Bot #1][11/30 02:09:52 PM]: Chopping Oak tree
[INFO][Bot #1][11/30 02:09:56 PM]: Script SBWoodcutter has paused!
[INFO][Bot #1][11/30 02:09:58 PM]: Script SBWoodcutter has resumed!
[INFO][Bot #1][11/30 02:09:58 PM]: Chopping Oak tree
		case CHOP:
			Entity Yew = objects.closest("Yew");
			Entity Willow = objects.closest("Willow");
			Entity Oak = objects.closest("Oak");
			if (Willow != null) {
				if (Willow.isVisible()) {
					Willow.interact("Chop down");
					log("Chopping Willow tree");
				} else {
					sleep(random(500, 700));
				}
			} else if (Oak != null) {
				if (Oak.isVisible()) {
					Oak.interact("Chop down");
					log("Chopping Oak tree");
				} else {
					sleep(random(500, 700));
				}
			} else if (Yew != null) {
				if (Yew.isVisible()) {
					Yew.interact("Chop down");
					log("Chopping Yew tree");
				} else {
					sleep(random(500, 700));
				}
			}
			break;

 

Have set a log for every tree type. Willow and Oak logs perfectly. But the Yew log doesn't show up.. so i'm guessing it doesn't read that peace of code..

[INFO][Bot #1][11/30 02:09:51 PM]: Started script : SBWoodcutter
[INFO][Bot #1][11/30 02:09:52 PM]: Chopping Oak tree
[INFO][Bot #1][11/30 02:09:56 PM]: Script SBWoodcutter has paused!
[INFO][Bot #1][11/30 02:09:58 PM]: Script SBWoodcutter has resumed!
[INFO][Bot #1][11/30 02:09:58 PM]: Chopping Oak tree
		case CHOP:
			Entity Yew = objects.closest("Yew");
			Entity Willow = objects.closest("Willow");
			Entity Oak = objects.closest("Oak");
			if (Willow != null) {
				if (Willow.isVisible()) {
					Willow.interact("Chop down");
					log("Chopping Willow tree");
				} else {
					sleep(random(500, 700));
				}
			} else if (Oak != null) {
				if (Oak.isVisible()) {
					Oak.interact("Chop down");
					log("Chopping Oak tree");
				} else {
					sleep(random(500, 700));
				}
			} else if (Yew != null) {
				if (Yew.isVisible()) {
					Yew.interact("Chop down");
					log("Chopping Yew tree");
				} else {
					sleep(random(500, 700));
				}
			}
			break;

add my skype: osbotsinatra1

  • Author

add my skype: osbotsinatra1

 

Will do. Problem is that i'm free from school in 5 mins. Can i come back later this day?

Will do. Problem is that i'm free from school in 5 mins. Can i come back later this day?

Yeah we can do this later. I also have school in an hour.

  • Author

Yeah we can do this later. I also have school in an hour.

 

Alright, thanks. Will contact you later this day.

 

Hi Osbot scripters!

 

I have been f*cking around with this all morning. I have no idea what i'm doing wrong. removing the } else { wont work either.. Oaks and Willows are working. Yews are not..

 

EDIT: Tried Else if statements. Didn't work either. 

		case CHOP:
			Entity Yew = objects.closest("Yew");
			Entity Willow = objects.closest("Willow");
			Entity Oak = objects.closest("Oak");
			if (Willow != null) {
				if (Willow.isVisible()) {
					Willow.interact("Chop down");
				} else {
					sleep(random(500, 700));
				}
			} else if (Oak != null) {
				if (Oak.isVisible()) {
					Oak.interact("Chop down");
				} else {
					sleep(random(500, 700));
				}
			} else if (Yew != null) {
				if (Yew.isVisible()) {
					Yew.interact("Chop down");
				} else {
					sleep(random(500, 700));
				}
			}
		case CHOP:
			Entity Willow = objects.closest("Willow");
			if (Willow != null) {
				if (Willow.isVisible()) {
					Willow.interact("Chop down");
				} else {
					sleep(random(500, 700));
				} 
				} else {
				Entity Oak = objects.closest("Oak");
				if (Oak != null) {
					if (Oak.isVisible()) {
						Oak.interact("Chop down");
					} else {
						sleep(random(500, 700));
					}
				} else {
					Entity Yew = objects.closest("Yew");
					if (Yew != null) {
						if (Yew.isVisible()) {
							Yew.interact("Chop down");
						} else {
							sleep(random(500, 700));
						}
					}
				}
			}

 

Probably just that there isn't a Yew tree nearby??

 

Also if you are near a Yew tree, and there is an Oak or Willow nearby it will try and cut those first.

 

I suggest you change your yew code to:

else {

    Entity Yew = getObjects().closest("Yew");
    if (Yew != null) {

        if (Yew.isVisible()) {

            log("Chopping Yew");
            Yew.interact("Chop down");
        } else {

            log("Yew is not visible");
            sleep(random(500, 700));
        }
    } else{
    
        log("Yew is null");
    }
}

And view the logger so you can see what's happening.

 

On a side note your code can be simplified to:

case CHOP:
    
    Entity yew = getObjects().closest("Yew"), 
    willow = getObjects().closest("Willow"),
    oak = getObjects().closest("Oak");

    if (willow != null && willow.isVisible()) willow.interact("Chop down");
    else if (oak != null && oak.isVisible()) oak.interact("Chop down");
    else if (yew != null && yew.isVisible()) yew.interact("Chop down");
    else sleep(random(500, 700));

Side note 2: variable names should always be lowercase

 

 

I would also suggest you take a look at Java Swing, there are some tutorials here on OSBot, and create a GUI that lets the user select which kind of tree they want to chop.

 

Edited by Explv

  • Author

Probably just that there isn't a Yew tree nearby??

Also if you are near a Yew tree, and there is an Oak or Willow nearby it will try and cut those first.

I suggest you change your yew code to:

else {    Entity Yew = getObjects().closest("Yew");    if (Yew != null) {        if (Yew.isVisible()) {            log("Chopping Yew");            Yew.interact("Chop down");        } else {            log("Yew is not visible");            sleep(random(500, 700));        }    } else{            log("Yew is null");    }}
And view the logger so you can see what's happening.

On a side note your code can be simplified to:

case CHOP:        Entity yew = getObjects().closest("Yew"),     willow = getObjects().closest("Willow"),    oak = getObjects().closest("Oak");    if (willow != null && willow.isVisible()) willow.interact("Chop down");    else if (oak != null && oak.isVisible()) oak.interact("Chop down");    else if (yew != null && yew.isVisible()) yew.interact("Chop down");    else sleep(random(500, 700));
Side note 2: variable names should always be lowercase

I would also suggest you take a look at Java Swing, there are some tutorials here on OSBot, and create a GUI that lets the user select which kind of tree they want to chop.

Hey! Thanks for the reply. I will try this after dinner. Thing is, i have a GUI. Works on willows and oaks. But the yew he cant find. Even tho i'm standing next to it. Maybe insert the id of the yew instead of the name?

And for the lower case vars. Thanks, really apriciate it!

Hey! Thanks for the reply. I will try this after dinner. Thing is, i have a GUI. Works on willows and oaks. But the yew he cant find. Even tho i'm standing next to it. Maybe insert the id of the yew instead of the name?

And for the lower case vars. Thanks, really apriciate it!

 

Feel free to PM me and I can take a look at the full source code for 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.