MySQLi Posted June 25, 2017 Share Posted June 25, 2017 So... This script will work.. kind of. If I start at the yew tree in East Varrock, it'll cut the yew, but after the yew is cut down, it'll run to the next closest yew on the other side of the castle. If I start it anywhere other then that yew tree, it won't walk to it. Can anyone tell me what's wrong with this.. Spoiler import org.osbot.rs07.api.map.Area; import org.osbot.rs07.api.model.RS2Object; import org.osbot.rs07.script.Script; import org.osbot.rs07.script.ScriptManifest; @ScriptManifest(name = "MyYewCutter", author = "MySQLi", version = 1.0, info = "Cuts yews in East Varrock", logo = "") public class Main extends Script { private State state; Area WC = new Area(3247,3472,0,0); Area Bank = new Area(3253,3420,0,0); private enum State{ CUT, WALKTOBANK, BANK, WALKTOTREE } private State getState(){ if(getInventory().isFull() && Bank.contains(myPlayer())){ return State.BANK; } if(getInventory().isFull() && !Bank.contains(myPlayer())){ return State.WALKTOBANK; } if(!getInventory().isFull() && WC.contains(myPlayer())){ return State.CUT; } if(!getInventory().isFull() && !WC.contains(myPlayer())){ return State.WALKTOTREE; } return State.BANK; } public void onStart(){ } public int onLoop() throws InterruptedException{ state = getState(); switch (state){ case BANK: if(!getBank().isOpen()){ getBank().open(); }else{ getBank().depositAll(); } case WALKTOBANK: getWalking().webWalk(Bank); break; case CUT: if (myPlayer().isAnimating()){ }else{ if(!myPlayer().isAnimating()){ } RS2Object yew = getObjects().closest("Yew"); if (yew != null){ yew.interact("Chop down"); } } break; case WALKTOTREE: getWalking().webWalk(WC); break; } return random(150,175); } } Quote Link to comment Share on other sites More sharing options...
Muffins Posted June 25, 2017 Share Posted June 25, 2017 do u have an axe in ur inventory Quote Link to comment Share on other sites More sharing options...
MySQLi Posted June 25, 2017 Author Share Posted June 25, 2017 I do not, it's equipped on my character. Quote Link to comment Share on other sites More sharing options...
Viston Posted June 25, 2017 Share Posted June 25, 2017 (edited) 33 minutes ago, MySQLi said: I do not, it's equipped on my character. You are just calling myPlayer. I think you need to do myPlayer.getPosition() Like this v if(!getInventory().isFull() && WC.contains(myPlayer.getPosition())){ return State.CUT; } Reason is, you want to check the yew area against your players current position. Edited June 25, 2017 by Visty Quote Link to comment Share on other sites More sharing options...
MySQLi Posted June 25, 2017 Author Share Posted June 25, 2017 2 minutes ago, Visty said: You are just calling myPlayer. I think you need to do myPlayer.getPosition() if(!getInventory().isFull() && WC.contains(myPlayer.getPosition())){ return State.CUT; } But WC has a stored x,y position, so wouldn't the client realize my current x,y and the x,y it should be at and move it there? Quote Link to comment Share on other sites More sharing options...
Viston Posted June 25, 2017 Share Posted June 25, 2017 (edited) Also, to make your player only cut the yew trees within the area you have selected, you have to do this v RS2Object yew = getObjects().closest(WC, "Yew"); As you can see, you are telling the bot to check the closest tree in the WC area, against the tree "Yew" Edited June 25, 2017 by Visty Quote Link to comment Share on other sites More sharing options...
MySQLi Posted June 25, 2017 Author Share Posted June 25, 2017 2 minutes ago, Visty said: Also, to make your player only cut the yew trees within the area you have selected, you have to do this v RS2Object yew = getObjects().closest(WC, "Yew"); As you can see, you are telling the bot to check the closest tree in the WC area, against the tree "Yew" Thank you, that fixes that, but with your other suggestion, it still won't walk to the Woodcutting location... I don't understand why it's not working. Quote Link to comment Share on other sites More sharing options...
Viston Posted June 25, 2017 Share Posted June 25, 2017 2 minutes ago, MySQLi said: But WC has a stored x,y position, so wouldn't the client realize my current x,y and the x,y it should be at and move it there? Yes, in your WalkToTree method, say something like v if (!WC.contains(myPlayer.getPosition()) { getWalking.walk(yew); } In this, you are saying if the player isn't in the WC area, let's walk to it. Quote Link to comment Share on other sites More sharing options...
MySQLi Posted June 25, 2017 Author Share Posted June 25, 2017 3 minutes ago, Visty said: Yes, in your WalkToTree method, say something like v if (!WC.contains(myPlayer.getPosition()) { getWalking.walk(yew); } In this, you are saying if the player isn't in the WC area, let's walk to it. 3 minutes ago, Visty said: Yes, in your WalkToTree method, say something like v if (!WC.contains(myPlayer.getPosition()) { getWalking.walk(yew); } In this, you are saying if the player isn't in the WC area, let's walk to it. I tried this, it still won't walk to the yew tree. I don't understand why. Quote Link to comment Share on other sites More sharing options...
Viston Posted June 25, 2017 Share Posted June 25, 2017 Just now, MySQLi said: I tried this, it still won't walk to the yew tree. I don't understand why. Show me the code you have written Quote Link to comment Share on other sites More sharing options...
MySQLi Posted June 25, 2017 Author Share Posted June 25, 2017 4 minutes ago, Visty said: Show me the code you have written import org.osbot.rs07.api.map.Area; import org.osbot.rs07.api.model.RS2Object; import org.osbot.rs07.script.Script; import org.osbot.rs07.script.ScriptManifest; @ScriptManifest(name = "MyYewCutter", author = "MySQLi", version = 1.0, info = "Cuts yews in East Varrock", logo = "") public class Main extends Script { private State state; Area WC = new Area(3247,3472,0,0); Area Bank = new Area(3253,3420,0,0); private enum State{ CUT, WALKTOBANK, BANK, WALKTOTREE } private State getState(){ if(getInventory().isFull() && Bank.contains(myPlayer())){ return State.BANK; } if(getInventory().isFull() && !Bank.contains(myPlayer())){ return State.WALKTOBANK; } if(!getInventory().isFull() && WC.contains(myPlayer().getPosition())){ return State.CUT; } if(!getInventory().isFull() && !WC.contains(myPlayer().getPosition())){ return State.WALKTOTREE; } return State.BANK; } public void onStart(){ } public int onLoop() throws InterruptedException{ state = getState(); switch (state){ case BANK: if(!getBank().isOpen()){ getBank().open(); }else{ getBank().depositAll(); } case WALKTOBANK: getWalking().webWalk(Bank); break; case CUT: if (myPlayer().isAnimating()){ }else{ if(!myPlayer().isAnimating()){ } RS2Object yew = getObjects().closest(WC, "Yew"); if (yew != null){ yew.interact("Chop down"); } } break; case WALKTOTREE: getWalking().webWalk(WC); break; } return random(150,175); } } Quote Link to comment Share on other sites More sharing options...
Viston Posted June 25, 2017 Share Posted June 25, 2017 (edited) 3 minutes ago, MySQLi said: Are you sure that your inventory is not full before walking to the tree? Also, are you sure that the area you have selected for the yew trees isn't including the bank as well? Edited June 25, 2017 by Visty Quote Link to comment Share on other sites More sharing options...
MySQLi Posted June 25, 2017 Author Share Posted June 25, 2017 4 minutes ago, Visty said: Are you sure that your inventory is not full before walking to the tree? Also, are you sure that the area you have selected for the yew trees isn't including the bank as well? Yes, inventory is empty, and I checked the coordinates too. Quote Link to comment Share on other sites More sharing options...
Viston Posted June 25, 2017 Share Posted June 25, 2017 (edited) 10 minutes ago, MySQLi said: Yes, inventory is empty, and I checked the coordinates too. I'm thinking it's because of your states. They all have the same if statements. I can't really identify the problem without logging each statement, and see where the issue is. If you want, I can help you via teamviewer. Edited June 25, 2017 by Visty Quote Link to comment Share on other sites More sharing options...
MySQLi Posted June 25, 2017 Author Share Posted June 25, 2017 Solved with help from Visty, thank you! 1 Quote Link to comment Share on other sites More sharing options...