Rudie Posted March 8, 2015 Share Posted March 8, 2015 (edited) In my firemaking script I'm working on I want that if it accidentally wants to light fires at a tile where already is a fire to move a coord. This is what I've tried: RS2Object fire = objects.closest("Fire"); if(fire.getY() == myPlayer().getY()) { mouse.click(myPlayer().getX(), myPlayer().getY() + 1, true); log("help"); } (Placed the log "help" there to debug and yes it does spam help in the console.) This doesn't work, I've also tried with the MessageListener like this: if (txt.contains("light a fire here")) { mouse.click(myPlayer().getX(), myPlayer().getY() + 1, true); sleep(random(150, 250)); } But none of it works, so I'm wondering is it broken in the API or is there another better way to do this? Cause I really need it. Thanks, Rudie. Edited March 8, 2015 by Rudie Quote Link to comment Share on other sites More sharing options...
Apaec Posted March 8, 2015 Share Posted March 8, 2015 Get the tile to the left of the fire, check if it's walkable to and then do localWalker.walk(position), instead of trying to hardcode it with the mouse Quote Link to comment Share on other sites More sharing options...
Rudie Posted March 8, 2015 Author Share Posted March 8, 2015 It just doesn't want to walk it just tries to light another log. Quote Link to comment Share on other sites More sharing options...
Twin Posted March 8, 2015 Share Posted March 8, 2015 It just doesn't want to walk it just tries to light another log. Is this an anywhere firemaker or is this for a specific place? Quote Link to comment Share on other sites More sharing options...
Lemons Posted March 8, 2015 Share Posted March 8, 2015 (edited) In my firemaking script I'm working on I want that if it accidentally wants to light fires at a tile where already is a fire to move a coord. This is what I've tried: RS2Object fire = objects.closest("Fire"); if(fire.getY() == myPlayer().getY()) { mouse.click(myPlayer().getX(), myPlayer().getY() + 1, true); log("help"); } (Placed the log "help" there to debug and yes it does spam help in the console.) This doesn't work, I've also tried with the MessageListener like this: if (txt.contains("light a fire here")) { mouse.click(myPlayer().getX(), myPlayer().getY() + 1, true); sleep(random(150, 250)); } But none of it works, so I'm wondering is it broken in the API or is there another better way to do this? Cause I really need it. Thanks, Rudie. This code... would never work. Your comparing players X/Y ingame coords to mouse coords, only increasing the mouse Y by 1, nice try though :p myPlayer().getPosition().translate(0, 1).interact("Walk here"); Should work. Edited March 8, 2015 by dudeami Quote Link to comment Share on other sites More sharing options...
Rudie Posted March 9, 2015 Author Share Posted March 9, 2015 This code... would never work. Your comparing players X/Y ingame coords to mouse coords, only increasing the mouse Y by 1, nice try though myPlayer().getPosition().translate(0, 1).interact("Walk here"); Should work. I get this error: The method interact(Bot, String...) in the type Position is not applicable for the arguments (String) Still need this, localwalker wont walk for me to that specific tile.. Quote Link to comment Share on other sites More sharing options...
Rudie Posted March 9, 2015 Author Share Posted March 9, 2015 I know what the problem is, it can't move just 1 tile it has to be more than a certain amount. If I changed it to +5 tiles it would work. Now, is there a way that it can move just 1 tile? Thanks. Quote Link to comment Share on other sites More sharing options...
Rudie Posted March 10, 2015 Author Share Posted March 10, 2015 Got it, this is working for me right now: RS2Object fire = objects.closest("Fire"); if(fire.getY() == myPlayer().getY() && fire.getX() == myPlayer().getX()) { int a = Integer.parseInt(""+myPlayer().getY()+""); int b = Integer.parseInt(""+a+"") + 1 ; int c = Integer.parseInt(""+myPlayer().getX()+""); int d = Integer.parseInt(""+c+"") + 1 ; Position path = new Position(d, b, 0); path.interact(bot, "Walk here"); log("ot works"); sleep(random(150, 250)); } Thanks for everyone who tried to help! Quote Link to comment Share on other sites More sharing options...
DragonAlpha Posted March 12, 2015 Share Posted March 12, 2015 fire.getX() is getting the X coordinate for the fire. You need to get the x and y coordinates then add 1 to this but then you are doing the click wrong. mouse.click cannot be fed coordinates. It clicks the position on the screen mouseX, mouseY. You need to calculate what the screen mouse coordinates are for tht tile. You are confusing the 2. Tile coordinates (position in runescape world) and mouse sxreen coordinates, where 0, 0 means the top left of the screen. Quote Link to comment Share on other sites More sharing options...
Botre Posted March 12, 2015 Share Posted March 12, 2015 Got it, this is working for me right now: RS2Object fire = objects.closest("Fire"); if(fire.getY() == myPlayer().getY() && fire.getX() == myPlayer().getX()) { int a = Integer.parseInt(""+myPlayer().getY()+""); int b = Integer.parseInt(""+a+"") + 1 ; int c = Integer.parseInt(""+myPlayer().getX()+""); int d = Integer.parseInt(""+c+"") + 1 ; Position path = new Position(d, b, 0); path.interact(bot, "Walk here"); log("ot works"); sleep(random(150, 250)); } Thanks for everyone who tried to help! int a = Integer.parseInt(""+myPlayer().getY()+""); int b = Integer.parseInt(""+a+"") + 1 ; int c = Integer.parseInt(""+myPlayer().getX()+""); What did I just read.... You take an int turn it into a string an then parse an int out of it again. Don't do that. Ever. 1 Quote Link to comment Share on other sites More sharing options...
Rudie Posted March 12, 2015 Author Share Posted March 12, 2015 int a = Integer.parseInt(""+myPlayer().getY()+""); int b = Integer.parseInt(""+a+"") + 1 ; int c = Integer.parseInt(""+myPlayer().getX()+""); What did I just read.... You take an int turn it into a string an then parse an int out of it again. Don't do that. Ever. I know it is a horrible way of doing it but I couldn't get it to work any other way, but it worked so I didn't care to change it. Quote Link to comment Share on other sites More sharing options...
Joseph Posted March 12, 2015 Share Posted March 12, 2015 I know it is a horrible way of doing it but I couldn't get it to work any other way, but it worked so I didn't care to change it. what he is saying is that those methods return an int already. what you have there is an int, then you convert it into string. Then once you have the string you convert it into an int again. int a = myPlayer().getY(); //works perfectly fine Quote Link to comment Share on other sites More sharing options...
Botre Posted March 12, 2015 Share Posted March 12, 2015 (edited) I know it is a horrible way of doing it but I couldn't get it to work any other way, but it worked so I didn't care to change it. RS2Object fire = objects.closest("Fire"); if (fire != null && fire.exists() && fire.getPosition().equals(myPosition())) { new Position(myPosition().getX() + 1, myPosition().getY() + 1, myPosition().getZ()).interact(getBot(), "Walk here"); sleep(random(150, 250)); } Edited March 12, 2015 by Botre Quote Link to comment Share on other sites More sharing options...
Rudie Posted March 12, 2015 Author Share Posted March 12, 2015 what he is saying is that those methods return an int already. what you have there is an int, then you convert it into string. Then once you have the string you convert it into an int again. int a = myPlayer().getY(); //works perfectly fine Just thought about it and yes I could have done that and might change it in the script to clean it up. But please keep in mind that I'm a learning Java developer and was just doing everything I could to get it to work. Thanks for pointing out that that is a stupid way to do it, that way I keep learning and keep getting better at programming in Java RS2Object fire = objects.closest("Fire"); if (fire != null && fire.exists() && fire.getPosition().equals(myPosition())) { new Position(myPosition().getX() + 1, myPosition().getY() + 1, myPosition().getZ()).interact(getBot(), "Walk here"); sleep(random(150, 250)); } I have tried doing it by doing myPosition.getX() + 1 but it would add the number right after the coord so like if the coord was 3444 it would change to 34441, I remembered this was a problem once in my class at javascript where we had to do something similiar to this and the teacher told us about parseInt, I looked it up if there was something like that in Java and eventually did it that way. Quote Link to comment Share on other sites More sharing options...
Botre Posted March 12, 2015 Share Posted March 12, 2015 Just thought about it and yes I could have done that and might change it in the script to clean it up. But please keep in mind that I'm a learning Java developer and was just doing everything I could to get it to work. Thanks for pointing out that that is a stupid way to do it, that way I keep learning and keep getting better at programming in Java Today you both solved a problem AND you learned something new. #winning (now go fix that conversion thingie ) Quote Link to comment Share on other sites More sharing options...