Twin Posted February 10, 2015 Share Posted February 10, 2015 (edited) 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 February 10, 2015 by twin 763 Quote Link to comment Share on other sites More sharing options...
CallMeDominic Posted February 10, 2015 Share Posted February 10, 2015 Check the Object ID or, if it doesn't change, check the model/actions. Quote Link to comment Share on other sites More sharing options...
Khaleesi Posted February 10, 2015 Share Posted February 10, 2015 yes use ID's or models Or maybe check the Actions on the object Quote Link to comment Share on other sites More sharing options...
boyyo11 Posted February 10, 2015 Share Posted February 10, 2015 (edited) 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 February 10, 2015 by boyyo11 Quote Link to comment Share on other sites More sharing options...
Apaec Posted February 10, 2015 Share Posted February 10, 2015 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 1 Quote Link to comment Share on other sites More sharing options...
boyyo11 Posted February 10, 2015 Share Posted February 10, 2015 ^ Do what apaec said thatd be your best bet than Quote Link to comment Share on other sites More sharing options...
Twin Posted February 10, 2015 Author Share Posted February 10, 2015 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 Quote Link to comment Share on other sites More sharing options...
Twin Posted February 28, 2015 Author Share Posted February 28, 2015 (edited) did not mean to post here. Edited February 28, 2015 by twin 763 Quote Link to comment Share on other sites More sharing options...
boyyo11 Posted March 31, 2015 Share Posted March 31, 2015 Yes you would, that would be the trap class, just holds information about your traps you have placed so you can continously work with all of them in ease. Quote Link to comment Share on other sites More sharing options...
Twin Posted March 31, 2015 Author Share Posted March 31, 2015 Yes you would, that would be the trap class, just holds information about your traps you have placed so you can continously work with all of them in ease. I get the class now I knew like nothing a month ago lol Quote Link to comment Share on other sites More sharing options...
Twin Posted April 1, 2015 Author Share Posted April 1, 2015 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 Quote Link to comment Share on other sites More sharing options...