t0r3 Posted March 21, 2019 Share Posted March 21, 2019 (edited) Hey It's me again Have a problem with my miner, - tried writing it different from what I'm used to; Tried using private voids and then putting them into onLoop. What can I improve and what is making my script not runnable? public class LSCopperMiner extends Script { private Area miningArea = new Area( 3228, 3145, 3229, 3145); private void walking(){ if (getInventory().isEmptyExcept("Bronze pickaxe","Iron pickaxe","Steel pickaxe", "Mithril pickaxe","Adamant pickaxe","Rune pickaxe" ) && !miningArea.contains(myPosition())){ log("Inventory is empty and miningArea does not contain my position, walking to mining area"); getWalking().webWalk(miningArea); } else if(getInventory().isFull() && !Banks.LUMBRIDGE_UPPER.contains(myPosition())) { log("Inventory is full, walking to LBank"); getWalking().webWalk(Banks.LUMBRIDGE_UPPER); } } private RS2Object copperRocks = getObjects().closest(7484,7453); private void levelUpWhile() { while (getDialogues().isPendingContinuation()){ if(getDialogues().clickContinue()){ log("Interacting with copperRocks again"); copperRocks.interact("Mine"); } } } private void mining() throws InterruptedException { if(copperRocks != null && !myPlayer().isAnimating() && !myPlayer().isMoving()){ log("Interacting with copperRocks"); copperRocks.interact("Mine"); log("Sleeping a bit before 'going afk'"); sleep(random(1000,1400)); log("Moving mouse outside of screen,'going afk'"); getMouse().moveOutsideScreen(); } } private void banking() throws InterruptedException { RS2Object bankBooth = getObjects().closest("Bank booth"); if(!getBank().isOpen() && bankBooth != null && Banks.LUMBRIDGE_UPPER.contains(myPosition())) { log("In LBank and Bank is not open, interacting with Bank"); bankBooth.interact("Bank"); log("Sleeping for 1.5-2.5 sec to avoid interacting with bank again"); sleep(random(1500, 2500)); } if(getBank().isOpen()) { log("Bank is open, depositing everything except pickaxes"); getBank().depositAllExcept("Bronze pickaxe","Iron pickaxe","Steel pickaxe", "Mithril pickaxe","Adamant pickaxe","Rune pickaxe"); } } @Override public int onLoop() throws InterruptedException { if(!miningArea.contains(myPosition()) || !Banks.LUMBRIDGE_UPPER.contains(myPosition())) { walking(); } else if(miningArea.contains(myPosition())){ levelUpWhile(); mining(); banking(); } return 1000; } } Edited March 21, 2019 by t0r3 Quote Link to comment Share on other sites More sharing options...
ThatGamerBlue Posted March 21, 2019 Share Posted March 21, 2019 You got your @ScriptManifest annotation? Quote Link to comment Share on other sites More sharing options...
Xx pk xX Posted March 21, 2019 Share Posted March 21, 2019 Also following line private RS2Object copperRocks = getObjects().closest(7484,7453); Should be in your mining() method. private void mining() throws InterruptedException { RS2Object copperRocks = getObjects().closest(7484,7453); if(copperRocks != null && !myPlayer().isAnimating() && !myPlayer().isMoving()){ log("Interacting with copperRocks"); copperRocks.interact("Mine"); log("Sleeping a bit before 'going afk'"); sleep(random(1000,1400)); log("Moving mouse outside of screen,'going afk'"); getMouse().moveOutsideScreen(); } } ^^ now it will try to find copperRocks obj always when you run mining() method, not only at start of the script. 1 Quote Link to comment Share on other sites More sharing options...
t0r3 Posted March 21, 2019 Author Share Posted March 21, 2019 3 minutes ago, ThatGamerBlue said: You got your @ScriptManifest annotation? Yeah I have the ScriptManifest up, able to locate it, click run and then it just doesnt do anything. When I click the Start button after choosing my script nothing happens. It doesn't even shift from the green play button to pause and stop button options.. Quote Link to comment Share on other sites More sharing options...
Script Kid Posted March 21, 2019 Share Posted March 21, 2019 33 minutes ago, t0r3 said: private RS2Object copperRocks = getObjects().closest(7484,7453); This value needs to be refreshed every time you try to mine a new rock. Do this in every method that uses this variable. 1 Quote Link to comment Share on other sites More sharing options...
t0r3 Posted March 21, 2019 Author Share Posted March 21, 2019 (edited) 7 minutes ago, Xx pk xX said: Also following line private RS2Object copperRocks = getObjects().closest(7484,7453); Should be in your mining() method. private void mining() throws InterruptedException { RS2Object copperRocks = getObjects().closest(7484,7453); if(copperRocks != null && !myPlayer().isAnimating() && !myPlayer().isMoving()){ log("Interacting with copperRocks"); copperRocks.interact("Mine"); log("Sleeping a bit before 'going afk'"); sleep(random(1000,1400)); log("Moving mouse outside of screen,'going afk'"); getMouse().moveOutsideScreen(); } } ^^ now it will try to find copperRocks obj always when you run mining() method, not only at start of the script. Thanks Ah, yeah I put all the way up there because I use it both in; private void levelUpWhile() { and, private void mining() throws InterruptedException { This is completely wrong? Put in both methods now, for reference 2 minutes ago, Script Kid said: This value needs to be refreshed every time you try to mine a new rock. Do this in every method that uses this variable. Thanks! Yeah I realize this now hahah Edited March 21, 2019 by t0r3 Quote Link to comment Share on other sites More sharing options...
t0r3 Posted March 21, 2019 Author Share Posted March 21, 2019 @Script Kid @Xx pk xX The script won't do anything after walking to miningSpot Any suggestions? Quote Link to comment Share on other sites More sharing options...
Xx pk xX Posted March 21, 2019 Share Posted March 21, 2019 miningArea has only 2 tiles? Following condition probably won't run - my guess is that player is not in mining area. else if(miningArea.contains(myPosition())){ Just make mining area bigger. Also make sure that copperRocks id's are correct. Then it should run 1 Quote Link to comment Share on other sites More sharing options...
t0r3 Posted March 21, 2019 Author Share Posted March 21, 2019 (edited) 39 minutes ago, Xx pk xX said: miningArea has only 2 tiles? Following condition probably won't run - my guess is that player is not in mining area. else if(miningArea.contains(myPosition())){ Just make mining area bigger. Also make sure that copperRocks id's are correct. Then it should run Yeah Ended up making this work; @Override public int onLoop() throws InterruptedException { if(!miningArea.contains(myPosition()) || !Banks.LUMBRIDGE_UPPER.contains(myPosition())) { walking(); } if (miningArea.contains(myPosition())) { levelUpWhile(); mining(); } if (Banks.LUMBRIDGE_UPPER.contains(myPosition())){ banking(); } return 1000; } Tried putting else in front of if (miningArea.contains(myPosition())) Why won't this work? ------------------------------------------------------------------------------------------------------------------------------------- Even though, - could just this work? The conditions for the different methods are already set in each one. Am I wrong? @Override public int onLoop() throws InterruptedException { if(myPlayer.exists()) { walking(); levelUpWhile(); mining(); banking(); } return 1000; } Thanks for being so helpful I know I'm asking many questions haha getting really into it Edited March 21, 2019 by t0r3 Quote Link to comment Share on other sites More sharing options...
Nebulae Posted March 22, 2019 Share Posted March 22, 2019 (edited) Quote Even though, - could just this work? The conditions for the different methods are already set in each one. Am I wrong? @Override public int onLoop() throws InterruptedException { if(myPlayer.exists()) { walking(); levelUpWhile(); mining(); banking(); } return 1000; } Thanks for being so helpful I know I'm asking many questions haha getting really into it That should work so long as all of your conditionals are correct. Easiest way to test that would be to just do it. The main things you have to ask yourself is calling any of those other methods while another one is happening going to screw with what your script tries to do? For instance if you call levelUpWhile() and the script is actually banking etc.. As for your second question regarding why sticking else in front of that if statement doesn't work i'm not sure why it isn't working, as logically it should as long as it's formatted like this: @Override public int onLoop() throws InterruptedException { if(!miningArea.contains(myPosition()) || !Banks.LUMBRIDGE_UPPER.contains(myPosition())) { walking(); } else if (miningArea.contains(myPosition())) { levelUpWhile(); mining(); } else if (Banks.LUMBRIDGE_UPPER.contains(myPosition())){ banking(); } return 1000; } Edited March 22, 2019 by Nebulae Quote Link to comment Share on other sites More sharing options...
HeyImJamie Posted March 22, 2019 Share Posted March 22, 2019 I haven't read all of the above comments, but the reason why your script wouldn't load is because you were trying to create your RSObject variable outside of the loop, where the script wouldn't have loaded properly. This was causing it to 'crash'. Quote Link to comment Share on other sites More sharing options...
bulv3 Posted March 28, 2019 Share Posted March 28, 2019 dude just watch Chris tutorials Quote Link to comment Share on other sites More sharing options...