June 10, 20196 yr Here is a walk function I made, the error occurs on the execute(walkEvent) line. public void walk(Area area) throws InterruptedException{ WebWalkEvent walkEvent = new WebWalkEvent(area); execute(walkEvent); while (!area.contains(myPlayer().getPosition())) { Thread.sleep(1000); } } This is called like this: walk(new Area(3189, 3273, 3189, 3272)); Does anyone know what is wrong with this function that would be causing it to throw a null pointer exception?
June 10, 20196 yr Not sure why it would be throwing an NPE, usually this happens when someone calls the wrong execute function, which you are not. Bit of a tip as well, that while loop is going to do nothing as it wont start until the webwalk event has finished. Could you paste the entire exception? Edited June 10, 20196 yr by Tom
June 10, 20196 yr Author 1 hour ago, Tom said: Not sure why it would be throwing an NPE, usually this happens when someone calls the wrong execute function, which you are not. Bit of a tip as well, that while loop is going to do nothing as it wont start until the webwalk event has finished. Could you paste the entire exception? The reason I have that loop there was for testing purposes because in a previous iteration I had a web walk event that led into a NPC interaction and the bot would try to interact with the NPC as it was walking before it got to the actual area and opened the door before the npc
June 10, 20196 yr Author 58 minutes ago, Malcolm said: This probably could throw an NPE if you have this in a separate class and don’t extend method provider in that class and exchange context. Although this should be pretty obvious as your IDE should highlight that for you as an error You don’t need to remove the parameter. You’d just call it like you have. Alternatively you could make a variable for your area and call walk(variable); My walk function is in a separate class that does extend the Method Provider. 1 hour ago, Tom said: Not sure why it would be throwing an NPE, usually this happens when someone calls the wrong execute function, which you are not. Bit of a tip as well, that while loop is going to do nothing as it wont start until the webwalk event has finished. Could you paste the entire exception? Osbot crashes as this is running so I can not copy paste, However here is a screenshot.
June 10, 20196 yr 1 hour ago, redgar72 said: My walk function is in a separate class that does extend the Method Provider. Osbot crashes as this is running so I can not copy paste, However here is a screenshot. Can you provide a copy of all of your script or at least up to where the error is occurring (line 62). You can pm me if you don't want to share it publicly. Also, I'm not sure why you included the sleep part. If a WebWalk event fails, you might as well just have it log out rather than constantly sleeping till it logs out anyways. There's definitely a better way to do whatever you are trying to do, but I would need to see the context. You can also check if a webWalk event is able to be completed before you even start walking. public boolean canWalk(Area area) { WebWalkEvent w = new WebWalkEvent(area); return w.prefetchRequirements(this); } This will return true if a destination is found and directions are created. In which case, there's really no reason it wouldn't reach the destination.
June 11, 20196 yr 8 hours ago, redgar72 said: My walk function is in a separate class that does extend the Method Provider. Osbot crashes as this is running so I can not copy paste, However here is a screenshot. If its in a different class, you need to either exchange context, or not extend method provider and use dependency injection instead, like so void walk(Script instance, Area area){ WebWalkEvent e = new WebWalkEvent(area); instance.execute(e); }
June 11, 20196 yr Author 11 hours ago, Tom said: If its in a different class, you need to either exchange context, or not extend method provider and use dependency injection instead, like so void walk(Script instance, Area area){ WebWalkEvent e = new WebWalkEvent(area); instance.execute(e); } I merged the two classes and I am still getting a NPE at the same line
June 11, 20196 yr 1 hour ago, redgar72 said: I merged the two classes and I am still getting a NPE at the same line Gonna need to see all your code, PM me if you like
Create an account or sign in to comment