mitsuki Posted January 9, 2021 Share Posted January 9, 2021 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 Quote Link to comment Share on other sites More sharing options...
Chris Posted January 9, 2021 Share Posted January 9, 2021 https://lmgtfy.app/?q=java+random 1 Quote Link to comment Share on other sites More sharing options...
Jarl Posted January 9, 2021 Share Posted January 9, 2021 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. 1 Quote Link to comment Share on other sites More sharing options...
Khaleesi Posted January 9, 2021 Share Posted January 9, 2021 public static int randInt(int min, int max) { Random rand = new Random(); return rand.nextInt((max - min) + 1) + min; } 1 Quote Link to comment Share on other sites More sharing options...
mitsuki Posted January 9, 2021 Author Share Posted January 9, 2021 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? Quote Link to comment Share on other sites More sharing options...
mitsuki Posted January 9, 2021 Author Share Posted January 9, 2021 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? Quote Link to comment Share on other sites More sharing options...
mitsuki Posted January 9, 2021 Author Share Posted January 9, 2021 Do I need to spread the positions out even more? They are already only just visible by zooming all the way out Quote Link to comment Share on other sites More sharing options...
Jarl Posted January 12, 2021 Share Posted January 12, 2021 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. 1 Quote Link to comment Share on other sites More sharing options...
mitsuki Posted January 14, 2021 Author Share Posted January 14, 2021 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? Quote Link to comment Share on other sites More sharing options...
Nbacon Posted January 14, 2021 Share Posted January 14, 2021 (edited) 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, 2021 by Nbacon 1 Quote Link to comment Share on other sites More sharing options...
Jarl Posted January 15, 2021 Share Posted January 15, 2021 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. 1 Quote Link to comment Share on other sites More sharing options...