Jump to content

How to have bot pick up birdsnare after a bird has been caught/it fell over


Twin

Recommended Posts

Reading through the api right now trying to understand it, but I'm still learning it. How would I make my bot fix a broken bird snare, or take a bird from one if it gets caught. Also, how would I keep my bot in a certain area so it doesn't wander off? Like I said i'm still trying to read the api but theres a bunch there to learn. Is there a getState for ground items? or something like that?

Edited by twin 763
Link to comment
Share on other sites

Well seeming that the above poster didnt seem to help ya much ill do my best to walk you through it without code cause I havent coded for Osbot in while so here is how itd work. First you should make a new class, I designed this one for you if you dont like it trash it do whatever thats your choice.

import java.util.ArrayList;

class Trap {
	private static ArrayList<Trap> traps = new ArrayList<Trap>();
	private int x;
	private int y;
	private int id;
	private Entity trap;
	
	public Trap(int x, int y, int id, Entity trap){
		this.x = x;
		this.y = y;
		this.id = id;
		this.trap = trap;
                traps.add(trap);
	}
	
	public boolean trapFell(){
		return trap.getId() != id;
	}
}

This may work it may not. You may have to change it. But aslong as when the trap falls, its id changes than it will return that it fell. If the ID doesnt change when it falls, replace the id information in the trap class to information about the model, than check againist the model and see. For added failsafe, make sure the trap you are checking is corresponding to the trap with the x, y your working with. The trap class is not complete, you would have to add a setter nd getter for the cord aswell. Good luck man

Edited by boyyo11
Link to comment
Share on other sites

If you haven't already, feel free to check out my scripting tutorial which outlines the very basics.

http://osbot.org/forum/topic/58775-a-beginners-guide-to-writing-osbot-scripts-where-to-get-started-by-apaec/

 

Firstly, to stop your bot leaving an area, we first have to define the area in question:

 

at the top of your script where you define all your variables, 

Area HUNTING_AREA = new Area(0,0,0,0);
// instead of 0,0,0,0, write the top right and bottom left coords in the format
// (Top right X, Top right Y, Bottom left X, Bottom left y);

Then, after defining your area, you need to check if the players in it. In this scenario, we want to make sure the player is not out of the area. We can do this by dropping a check at the top of the onLoop:

if (!HUNTING_AREA.contains(myPlayer())) { //if you're not standing in the hunting area
    log("Returning to Hunting Area");
    localWalker.walk(HUNTING_AREA.getRandomPosition(0)); //Walks into hunting area
}

In light to your other question about the bird traps, you first need to find out what changes when you catch a bird. I.e, does the name change? do the actions change? does a single action change? Does the id change  (this is a last resort) ?

 

Once you figure out what changes, let me know and we can figure things out from there.

 

As for a fallen over trap, at the top of your onloop, just put:

GroundItem fallenSnare = groundItems.closest("Snare"); //whatever the name is, and may have called this wrong
if (fallenSnare != null && fallenSnare.exists()) {
    fallenSnare.interact("Take");
    sleep(500);
}

Any other problems, just let me know. Oh yea and i wrote the code all in the reply box so forgive me if I made any typos / mistakes

 

Apaec

  • Like 1
Link to comment
Share on other sites

If you haven't already, feel free to check out my scripting tutorial which outlines the very basics.

http://osbot.org/forum/topic/58775-a-beginners-guide-to-writing-osbot-scripts-where-to-get-started-by-apaec/

 

Firstly, to stop your bot leaving an area, we first have to define the area in question:

 

at the top of your script where you define all your variables, 

Area HUNTING_AREA = new Area(0,0,0,0);
// instead of 0,0,0,0, write the top right and bottom left coords in the format
// (Top right X, Top right Y, Bottom left X, Bottom left y);

Then, after defining your area, you need to check if the players in it. In this scenario, we want to make sure the player is not out of the area. We can do this by dropping a check at the top of the onLoop:

if (!HUNTING_AREA.contains(myPlayer())) { //if you're not standing in the hunting area
    log("Returning to Hunting Area");
    localWalker.walk(HUNTING_AREA.getRandomPosition(0)); //Walks into hunting area
}

In light to your other question about the bird traps, you first need to find out what changes when you catch a bird. I.e, does the name change? do the actions change? does a single action change? Does the id change  (this is a last resort) ?

 

Once you figure out what changes, let me know and we can figure things out from there.

 

As for a fallen over trap, at the top of your onloop, just put:

GroundItem fallenSnare = groundItems.closest("Snare"); //whatever the name is, and may have called this wrong
if (fallenSnare != null && fallenSnare.exists()) {
    fallenSnare.interact("Take");
    sleep(500);
}

Any other problems, just let me know. Oh yea and i wrote the code all in the reply box so forgive me if I made any typos / mistakes

 

Apaec

 

Thank you for this! Defiantly helped a lot since i'm still new with java, only about 6 months experience. I didn't even have any idea where to look in the api to find some of this since there's a lot there. Let me see if I can use this to get something basic out(just functionally, really) and I'll get back to you! thanks again =)

Well seeming that the above poster didnt seem to help ya much ill do my best to walk you through it without code cause I havent coded for Osbot in while so here is how itd work. First you should make a new class, I designed this one for you if you dont like it trash it do whatever thats your choice.

import java.util.ArrayList;

class Trap {
	private static ArrayList<Trap> traps = new ArrayList<Trap>();
	private int x;
	private int y;
	private int id;
	private Entity trap;
	
	public Trap(int x, int y, int id, Entity trap){
		this.x = x;
		this.y = y;
		this.id = id;
		this.trap = trap;
                traps.add(trap);
	}
	
	public boolean trapFell(){
		return trap.getId() != id;
	}
}

This may work it may not. You may have to change it. But aslong as when the trap falls, its id changes than it will return that it fell. If the ID doesnt change when it falls, replace the id information in the trap class to information about the model, than check againist the model and see. For added failsafe, make sure the trap you are checking is corresponding to the trap with the x, y your working with. The trap class is not complete, you would have to add a setter nd getter for the cord aswell. Good luck man

 

I'm confused with this. Would I have to make another class with my project then make the snare object?Also, I never really thought arrays were useful so thanks for proving me wrong lol

Link to comment
Share on other sites

  • 3 weeks later...
  • 1 month later...

If you haven't already, feel free to check out my scripting tutorial which outlines the very basics.

http://osbot.org/forum/topic/58775-a-beginners-guide-to-writing-osbot-scripts-where-to-get-started-by-apaec/

 

Firstly, to stop your bot leaving an area, we first have to define the area in question:

 

at the top of your script where you define all your variables, 

Area HUNTING_AREA = new Area(0,0,0,0);
// instead of 0,0,0,0, write the top right and bottom left coords in the format
// (Top right X, Top right Y, Bottom left X, Bottom left y);

Then, after defining your area, you need to check if the players in it. In this scenario, we want to make sure the player is not out of the area. We can do this by dropping a check at the top of the onLoop:

if (!HUNTING_AREA.contains(myPlayer())) { //if you're not standing in the hunting area
    log("Returning to Hunting Area");
    localWalker.walk(HUNTING_AREA.getRandomPosition(0)); //Walks into hunting area
}

In light to your other question about the bird traps, you first need to find out what changes when you catch a bird. I.e, does the name change? do the actions change? does a single action change? Does the id change  (this is a last resort) ?

 

Once you figure out what changes, let me know and we can figure things out from there.

 

As for a fallen over trap, at the top of your onloop, just put:

GroundItem fallenSnare = groundItems.closest("Snare"); //whatever the name is, and may have called this wrong
if (fallenSnare != null && fallenSnare.exists()) {
    fallenSnare.interact("Take");
    sleep(500);
}

Any other problems, just let me know. Oh yea and i wrote the code all in the reply box so forgive me if I made any typos / mistakes

 

Apaec

 

Thanks buddy tongue.png

 

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