Satan Posted June 6, 2019 Share Posted June 6, 2019 (edited) Hi all, I'm working on a script. There are no errors in my script and no error messages appear, This is not the first script I have made and I like to believe I have a decent amount of scripting knowledge. For some reason, the script just likes to sit still after having webwalked to the bank / field. Not doing anything, not logging anything even though I have a log messages troughout my whole script, also in the beginning of the onloop and before calling the actual methods. The weird thing is if I pause and then resume the script it will run as expected. (for a couple of trips) And sometimes runs fine for like ~10 trips. import org.osbot.rs07.api.map.Area; import org.osbot.rs07.api.map.constants.Banks; import org.osbot.rs07.api.model.Entity; import org.osbot.rs07.event.WebWalkEvent; import org.osbot.rs07.script.Script; import org.osbot.rs07.script.ScriptManifest; import org.osbot.rs07.utility.Condition; import org.osbot.rs07.utility.ConditionalSleep; @ScriptManifest(author = "contiez", info = "Farms", logo = "", name = "potato", version = 1.0) public class potato extends Script { private int itemid = 1942; private int world = 0; @Override public int onLoop() throws InterruptedException { log("Loop"); getPotatos(); return (random(400, 600)); } private void getPotatos() throws InterruptedException { log("method 1"); Area field = new Area(3155, 3290, 3140, 3268); Area pregate = new Area(3143, 3292, 3146, 3294); Entity potato = objects.closest("Potato"); if (world == 0) { world = worlds.getCurrentWorld(); } if (!getInventory().isFull()) { if (!field.contains(myPlayer())) { log("walk to field"); WebWalkEvent webEvent = new WebWalkEvent(field); webEvent.setBreakCondition(new Condition() { @Override public boolean evaluate() { return field.contains(myPlayer()); } }); execute(webEvent); } else if (field.contains(myPlayer()) && getMap().canReach(potato)) { if (potato != null) potato.interact("Pick"); new ConditionalSleep(750, 500) { @Override public boolean condition() throws InterruptedException { return myPlayer().isAnimating() && myPlayer().isMoving(); } }.sleep(); } else if (field.contains(myPlayer()) && !getMap().canReach(potato)) { log("walk to gate"); WebWalkEvent webEvent = new WebWalkEvent(pregate); webEvent.setBreakCondition(new Condition() { @Override public boolean evaluate() { return pregate.contains(myPlayer()); } }); execute(webEvent); } } else if (getInventory().isFull()) { bank(); } } private void bank() throws InterruptedException { if (Banks.DRAYNOR.contains(myPlayer())) { if (getBank().isOpen()) { getBank().depositAll(); } else { getBank().open(); } } else { WebWalkEvent webEvent = new WebWalkEvent(Banks.DRAYNOR); log("walk to bank"); webEvent.setBreakCondition(new Condition() { @Override public boolean evaluate() { return Banks.DRAYNOR.contains(myPlayer()); } }); execute(webEvent); } } } Help would be really appreciated! Edited June 8, 2019 by Satan Quote Link to comment Share on other sites More sharing options...
Neanel Posted June 6, 2019 Share Posted June 6, 2019 Place a log after "execute(webEvent)" & see if it ever gets there, if it does you know the problem is indeed with webwalking, when do you exactly call this function? If it's not, place logs throughout the script & see which one shows up last to know where exactly it failed. Quote Link to comment Share on other sites More sharing options...
Satan Posted June 6, 2019 Author Share Posted June 6, 2019 14 minutes ago, Neanel said: Place a log after "execute(webEvent)" & see if it ever gets there, if it does you know the problem is indeed with webwalking, when do you exactly call this function? If it's not, place logs throughout the script & see which one shows up last to know where exactly it failed. Hey, thanks for replying. It always gets to where it needs to be, and logs: "WebWalkingEvent; Terminated because of break condition!" in the console. weirdly enough that is also the last method being called before it stops and just stands there. Even after restarting the script it does not seem to do anything now, where as before it did. Note that i didnt change anything in the script. Quote Link to comment Share on other sites More sharing options...
Neanel Posted June 6, 2019 Share Posted June 6, 2019 Are you checking if the player is already in the area before calling the webwalk event? Otherwise it would just be stuck in a loop. if suddenly you’re script isn’t doing anything you might wanna reinstall everything & check if there are no nullpointers when assigning a value to a variable. Quote Link to comment Share on other sites More sharing options...
Satan Posted June 6, 2019 Author Share Posted June 6, 2019 5 minutes ago, Neanel said: Are you checking if the player is already in the area before calling the webwalk event? Otherwise it would just be stuck in a loop. if suddenly you’re script isn’t doing anything you might wanna reinstall everything & check if there are no nullpointers when assigning a value to a variable. Thanks again, but yes I do checks before calling any method and there are null checks troughout the script, also if there were to be a NPE it would log it to the console i believe. Quote Link to comment Share on other sites More sharing options...
Token Posted June 6, 2019 Share Posted June 6, 2019 Always add an else case at the end and print an error message in there, it's most likely a logical problem where none of your conditions are met Quote Link to comment Share on other sites More sharing options...
Satan Posted June 6, 2019 Author Share Posted June 6, 2019 5 minutes ago, Token said: Always add an else case at the end and print an error message in there, it's most likely a logical problem where none of your conditions are met Thanks for replying! Except how would this explain the log message at the top of the onLoop() not printing? It is not inside another block or anything. Quote Link to comment Share on other sites More sharing options...
Neanel Posted June 6, 2019 Share Posted June 6, 2019 Could you place a log in all your statements & show us the output? Place variables in the logs so you can track them. Quote Link to comment Share on other sites More sharing options...
Promo Posted June 6, 2019 Share Posted June 6, 2019 new WebWalkEvent(shelfArea) How does shelfArea variable look like? Can't find it in your blok of code. Quote Link to comment Share on other sites More sharing options...
Token Posted June 6, 2019 Share Posted June 6, 2019 30 minutes ago, Satan said: Thanks for replying! Except how would this explain the log message at the top of the onLoop() not printing? It is not inside another block or anything. I don't see any onLoop in there nor the code running after webwalking so I can't provide any info on that Quote Link to comment Share on other sites More sharing options...
Satan Posted June 6, 2019 Author Share Posted June 6, 2019 37 minutes ago, Promo said: new WebWalkEvent(shelfArea) How does shelfArea variable look like? Can't find it in your blok of code. final private Area shelfArea = new Area(3087, 3251, 3094, 3255); Quote Link to comment Share on other sites More sharing options...
Neanel Posted June 6, 2019 Share Posted June 6, 2019 So could you post the log output? Then it'll be clearer what the problem is Quote Link to comment Share on other sites More sharing options...
Satan Posted June 8, 2019 Author Share Posted June 8, 2019 On 6/6/2019 at 2:25 PM, Token said: I don't see any onLoop in there nor the code running after webwalking so I can't provide any info on that On 6/6/2019 at 4:21 PM, Neanel said: So could you post the log output? Then it'll be clearer what the problem is I put the full code in the OP now. Did change what the script collects but the banking and walking is identical. Hopefully y'all can help. Quote Link to comment Share on other sites More sharing options...
Juggles Posted June 8, 2019 Share Posted June 8, 2019 Webwalker can walk 2-3 tiles outside your area and believes it Is in the area. You need to make the webwalker walk to the center Quote Link to comment Share on other sites More sharing options...
Promo Posted June 12, 2019 Share Posted June 12, 2019 On 6/8/2019 at 9:20 PM, Juggles said: Webwalker can walk 2-3 tiles outside your area and believes it Is in the area. You need to make the webwalker walk to the center So rather walk to a position and then check if player is inside area or is there a getCenterPosition option for Area? Quote Link to comment Share on other sites More sharing options...