January 9, 20215 yr So I understand how to declare a path, and walk the path. What I'm trying to do is declare 3 paths that all go to the same location, but using different tile combinations, and then make my script randomly select a path to take, making it more random, and less boy like. Has Java got a built in random function that I can tell it to return a random between 0 and 2, and then make it walk the path correlating to that number? Sorry if I'm being confusing
January 9, 20215 yr Like chris mentioned, you can use Random.nextInt(3) or osbot's random(0,2). If your 3 paths are similar, you probably don't need to do this kind of thing because osbot doesn't always click on the exact same tiles.
January 9, 20215 yr public static int randInt(int min, int max) { Random rand = new Random(); return rand.nextInt((max - min) + 1) + min; }
January 9, 20215 yr Author 8 hours ago, Chris said: https://lmgtfy.app/?q=java+random 8 hours ago, Khaleesi said: public static int randInt(int min, int max) { Random rand = new Random(); return rand.nextInt((max - min) + 1) + min; } Thank you for the help guys! 8 hours ago, Jarl said: Like chris mentioned, you can use Random.nextInt(3) or osbot's random(0,2). If your 3 paths are similar, you probably don't need to do this kind of thing because osbot doesn't always click on the exact same tiles. Yeah, I appreciate that, just thought that it couldn't hurt to make my script seem more random, right?
January 9, 20215 yr Author List<Position> pathToSewer = new ArrayList<>(); @Override public void onStart() { log("Let's get started!"); pathToSewer.add(new Position(3246, 3433, 0)); pathToSewer.add(new Position(3246, 3450, 0)); pathToSewer.add(new Position(3238, 3457, 0)); } public int onLoop() throws InterruptedException { if (varrockBank.contains(myPlayer()) && !getInventory().isFull()) { log("Walking to sewer"); getWalking().walkPath(pathToSewer); } return random(2000, 5000); } So i'm using the walkPath function, but basically, it walks my player to the first position on the path, and even once I reach the tile, the script clicks on the exact tile to ensure I have moved to it. It doesn't do this for any other position of the path? Anyone know what could be causing this?
January 9, 20215 yr Author Do I need to spread the positions out even more? They are already only just visible by zooming all the way out
January 12, 20215 yr On 1/9/2021 at 7:04 AM, mitsuki said: Do I need to spread the positions out even more? They are already only just visible by zooming all the way out No. Your positions were too spread out. You need to make the positions closer for the part where the script keeps clicking on the same tile.
January 14, 20215 yr Author Is there any other way to declare the path before the onstart or onloop? I currently just add all of the positions of the path in onStart with: @Override public void onStart() { log("Let's get started!"); pathToSewer.add(new Position(3246, 3433, 0)); pathToSewer.add(new Position(3246, 3450, 0)); pathToSewer.add(new Position(3238, 3457, 0)); } But is there any other way to declare it outside of the loops? Or is adding each position on startup the best method?
January 14, 20215 yr 1 hour ago, mitsuki said: ? I thinks this will work static{ pathToSewer.add(new Position(3246, 3433, 0)); pathToSewer.add(new Position(3246, 3450, 0)); pathToSewer.add(new Position(3238, 3457, 0)); } or List<Position> pathToSewer = new ArrayList<Position>(Arrays.asList(new Position[]{new Position(3246, 3433, 0), new Position(3246, 3450, 0), new Position(3238, 3457, 0)})); or use https://explv.github.io/?centreX=3108¢reY=3315¢reZ=0&zoom=7 Edited January 14, 20215 yr by Nbacon
January 15, 20215 yr private static final List<Position> PATH_TO_SEWER = Arrays.asList( new Position(3246, 3433, 0), new Position(3246, 3450, 0), new Position(3238, 3457, 0) ); You can put this at the top, inside the class but outside the methods. It is not a must but it is a good idea to follow java naming conventions. Constants should be declared in capitals.
Create an account or sign in to comment