magoalucard Posted June 16, 2018 Share Posted June 16, 2018 i need to write a construction script for my bots, but i need some help, because i'ts bugs alot Spoiler Area areapt = new Area(2955, 3226, 2950, 3221); private void doLarder() throws InterruptedException { RS2Object Larder = getObjects().closest("Larder space"); RS2Object Portalf = getObjects().closest(15478); RS2Object Larder2 = getObjects().closest("Larder"); RS2Widget Oak = getWidgets().getWidgetContainingText("Oak larder"); if(!getMap().isInHouse() && areapt.contains(myPlayer().getPosition()) && Portalf.hasAction("Build mode") && Portalf.isVisible() && getInventory().getAmount("Oak plank") >= { Portalf.interact("Build mode"); new ConditionalSleep (5000, 500) { @Override public boolean condition() { return areapt.contains(myPlayer().getPosition()); } }.sleep(); }if(getMap().isInHouse() && !Larder.isVisible() && !myPlayer().isAnimating()) { getWalking().walk(Larder); } if (Larder.isVisible() && !myPlayer().isAnimating()) { Larder.interact("Build"); sleep(random(400,700)); new ConditionalSleep (5000, 500) { @Override public boolean condition() { return Oak.isVisible(); } }.sleep(); if(Oak.isVisible() || Oak != null ) { getKeyboard().typeString("2"); log("building"); new ConditionalSleep (5000, 500) { @Override public boolean condition() { return !myPlayer().isAnimating(); } }.sleep(); } } if (Larder2.isVisible() && Larder2.hasAction("Remove")) { Larder2.interact("Remove"); sleep (random(600,700)); getKeyboard().typeString("1"); } } @Override public int onLoop() throws InterruptedException { if(skills.getStatic(Skill.CONSTRUCTION) > 33) { doLarder(); } when i build a new oak larder, this codes starts to send this logger notes and heavly lagging Error in script executor! java.lang.NullPointerException at Construction.doLarder(Construction.java:53) at Construction.onLoop(Construction.java:71) at org.osbot.rs07.event.ScriptExecutor$InternalExecutor.run(kl:223) at java.lang.Thread.run(Unknown Source) Quote Link to comment Share on other sites More sharing options...
Night Posted June 16, 2018 Share Posted June 16, 2018 You should learn some basic Java before attempting to script. Quote Link to comment Share on other sites More sharing options...
Dab in a Lab Posted June 16, 2018 Share Posted June 16, 2018 Null check the Larder if (Larder != null) // You're code Quote Link to comment Share on other sites More sharing options...
FrostBug Posted June 16, 2018 Share Posted June 16, 2018 9 hours ago, Dab in a Lab said: Null check the Larder if (Larder != null) // You're code // You are code 1 4 Quote Link to comment Share on other sites More sharing options...
Canidae Posted June 16, 2018 Share Posted June 16, 2018 16 hours ago, Night said: You should learn some basic Java before attempting to script. Exactly. You are first using methods on an object and are then nullchecking it for example. Quote Link to comment Share on other sites More sharing options...