jelleplomp Posted March 24, 2015 Share Posted March 24, 2015 Hi everybody, I need some help, I'm trying to make a monkfighter that will auto heal itself on the monk itself, now i already have this bit of code: private void heal() throws InterruptedException { NPC Monk = (NPC)this.npcs.closest(new String[] { "Monk" }); if(Monk != null && !myPlayer().isUnderAttack() && !Monk.isUnderAttack()) { Monk.interact(new String[] { "Talk-to" }); this.status = "healing at Monk"; getInterfaces().get(231).getChild(2).interact(new String[] { "continue" }); getInterfaces().get(219).getChild(1).interact(new String[] { "can" }); sleep(random(200,300)); getInterfaces().get(217).getChild(2).interact(new String[] { "continue" }); sleep(random(200,300)); getInterfaces().get(231).getChild(2).interact(new String[] { "continue" }); sleep(random(1000, 1500)); } } but in the loop when its opening the interfaces and starting to interact at "can", the onloop method refers back to this method so it will all start over again, meaning it will never go further than this line: getInterfaces().get(231).getChild(2).interact(new String[] { "continue" }); so how do i do this? thanks in advance, Jelleplomp Quote Link to comment Share on other sites More sharing options...
Khaleesi Posted March 24, 2015 Share Posted March 24, 2015 (edited) You are getting an NPE error (nullpointer Exception) If (231,2) doesn't get found it will return null. So you do null.interact("Continue"); (and you can't really interact with something that doesn't exist right?) You should stop using interfaces since the are deprecated. Use RS2Widget instead. You basicly to this: RS2Widget chat1 = widgets.get(231,2) if(chat1 != null && chat1.isVisible()) chat1.interact("Continue"); Why are you using: (Did you decompile code? Decompilers generate this kind of code) .interact(new String[] { "Continue" }); You can just do: .interact("Continue"); Goodluck! Khaleesi Edited March 24, 2015 by Khaleesi Quote Link to comment Share on other sites More sharing options...
iJodix Posted March 24, 2015 Share Posted March 24, 2015 Umm, this should work; // Didn't test if (!myPlayer().isInteracting(monk))) { // NOT INTERACTING if (monk != null) { // IF EXISTS if (monk.isVisible()) { // IS VISIBLE if (!dialogues.inDialogue()) { // NOT IN DIALOGUE monk.interact("Talk-to"); // INTERACTS log("Talking to monk"); // LOG sleep(random(500, 900)); // SLEEPS } } } else if (dialogues.inDialogue()) { // IF IN DIALOGUE dialogues.clickContinue(); // CLICKS ON THE CONTINUE sleep(random(600, 1000)); // SLEEPS dialogues.selectOption("Ok"); // GIVE THIS AN OPTION sleep(random(2500, 3500)); // SLEEPS } } Quote Link to comment Share on other sites More sharing options...
Alek Posted March 24, 2015 Share Posted March 24, 2015 Not sure why you are casting NPC or why you are using arrays in the constructors. Try this: NPC monk = npcs.closest("Monk"); if(monk != null){ monk.interact("Talk-to"); //Conditional sleep until dialogues.isInDialogue(); dialogues.completeDialogue("can"); } Dialogues API: http://osbot.org/api/org/osbot/rs07/api/Dialogues.html Quote Link to comment Share on other sites More sharing options...
jelleplomp Posted March 24, 2015 Author Share Posted March 24, 2015 thanks everyone (: Quote Link to comment Share on other sites More sharing options...