Freak Posted June 7, 2014 Share Posted June 7, 2014 import java.awt.Rectangle; import org.osbot.legacy.script.mouse.RectangleDestination; import org.osbot.rs07.api.map.Position; import org.osbot.rs07.api.model.Entity; import org.osbot.rs07.api.model.GroundItem; import org.osbot.rs07.api.ui.Tab; import org.osbot.rs07.script.Script; import org.osbot.rs07.script.ScriptManifest; import org.osbot.rs07.utility.Area; @ScriptManifest(author="Freak",info="Mines Tin in Lumb Swamp",logo="",name="Freaky Miner", version = 0.1) public class Tin extends Script { private enum State { MINE, WALKTOMINE, COLLECTPICK, HOMETELE}; public static final Area Tele = new Area(3232,3209,3215,3229); public static final Area Lada = new Area(3229,3214, 3230, 3225); public static final Area Lada2 = new Area(3228,3223, 0, 0); ; public static final Position Roof = new Position(3229,3214, 2); public static final Position Roof2 = new Position(3229,3223, 2); public static final Position Roof3 = new Position(3228,3213, 2); public static final Position Roof4 = new Position(3228,3224, 2); @Override public void onStart(){ } private State getState() { if(!inventory.contains("Bronze pickaxe")){ if(Tele.contains(myPlayer())){ return State.COLLECTPICK; } }if(!Tele.contains(myPlayer())){ return State.HOMETELE; } return State.MINE; } public int onLoop() throws InterruptedException { switch (getState()) { case COLLECTPICK: Entity Door = objects.closest("Door"); if(Door.exists()){ mouse.setSpeed(2); if(!Door.interact("Close")){ Door.interact("Open"); } } sleep(random(250,3500)); Entity Ladder = objects.closest("Ladder"); Ladder.interact("Climb-up"); if(myPlayer().getPosition().equals(Roof)){ GroundItem x = this.groundItems.closest("Bronze pickaxe"); if (x != null && x.exists()) { x.interact("Take"); } }if(myPlayer().getPosition().equals(Roof2)){ GroundItem x = this.groundItems.closest("Bronze pickaxe"); if (x != null && x.exists()) { x.interact("Take"); } }if(myPlayer().getPosition().equals(Roof3)){ GroundItem x = this.groundItems.closest("Bronze pickaxe"); if (x != null && x.exists()) { x.interact("Take"); } }if(myPlayer().getPosition().equals(Roof4)){ log("Here"); GroundItem x = this.groundItems.closest("Bronze pickaxe"); if (x != null && x.exists()) { x.interact("Take"); } } log("error"); objects.closest("Ladder").interact("Climb-up"); sleep(random(250,3500)); log("hometele"); break; case HOMETELE: tabs.open(Tab.MAGIC); Rectangle optionRect = new Rectangle(571, 238, 10, 10); RectangleDestination optionDestination = new RectangleDestination (optionRect); if(!myPlayer().isAnimating()){ mouse.move(optionDestination); mouse.click(optionDestination,false); sleep(random(300000,400000)); } break; case MINE: break; case WALKTOMINE: break; default: break;} return 0; } } gives the error [ERROR][Bot #1][06/07 12:24:04 PM]: Error in script executor! java.lang.NullPointerException at Tin.onLoop(Tin.java:63) at org.osbot.rs07.event.ScriptExecutor$InternalExecutor.run(ri:145) at java.lang.Thread.run(Unknown Source) Link to comment Share on other sites More sharing options...
Precise Posted June 7, 2014 Share Posted June 7, 2014 which line is 63? because that is where the error is occurring. Link to comment Share on other sites More sharing options...
Freak Posted June 7, 2014 Author Share Posted June 7, 2014 which line is 63? because that is where the error is occurring. if(Door.exists()){ How do I check if a door is visible? Link to comment Share on other sites More sharing options...
Precise Posted June 7, 2014 Share Posted June 7, 2014 if(Door.exists()){ How do I check if a door is visible? you are throwing a NullPointerException. to resolve, change it to if(Door != null && Door.exists) { } to check if it is visible do Door.getPosition.isVisible() 1 Link to comment Share on other sites More sharing options...
Freak Posted June 7, 2014 Author Share Posted June 7, 2014 you are throwing a NullPointerException. to resolve, change it to if(Door != null && Door.exists) { } to check if it is visible do Door.getPosition.isVisible() Thank you very much! One quick question, if the door isn't visible how do I rotate the camera to the entity? Link to comment Share on other sites More sharing options...
Precise Posted June 7, 2014 Share Posted June 7, 2014 http://osbot.org/osbot2_api/org/osbot/rs07/api/Camera.html Have a look through the api glad I could help. Link to comment Share on other sites More sharing options...
Freak Posted June 7, 2014 Author Share Posted June 7, 2014 http://osbot.org/osbot2_api/org/osbot/rs07/api/Camera.html Have a look through the api glad I could help. 1 Link to comment Share on other sites More sharing options...
Precise Posted June 7, 2014 Share Posted June 7, 2014 shoot me a pm if you have any other questions ^_^ 1 Link to comment Share on other sites More sharing options...
Joseph Posted June 7, 2014 Share Posted June 7, 2014 This will kill you import org.osbot.legacy.script.mouse.RectangleDestination; import org.osbot.rs07.api.map.Position; import org.osbot.rs07.api.model.Entity; import org.osbot.rs07.api.model.GroundItem; import org.osbot.rs07.api.ui.Tab; import org.osbot.rs07.script.Script; import org.osbot.rs07.script.ScriptManifest; import org.osbot.rs07.utility.Area; Change the first line to make it match the rest 2 Link to comment Share on other sites More sharing options...
Apaec Posted June 16, 2014 Share Posted June 16, 2014 Also, do ctrl+alt+f once in a while 1 Link to comment Share on other sites More sharing options...