HelloPeeps Posted January 18, 2014 Share Posted January 18, 2014 (edited) I've made a stew buyer, it purchases stews from the pub in seers and banks them, it works fairly well but as it's clicking through the chat talking to the bartender it sometimes misses a click then a load of error appear and it starts from the beginning clicking the bartender again and going through the chat again. How to I make it so that it tried a couple times trying to click continue (say if the chat lags) before restarting from the beginning and clicking the NPC? I've turned the speed down to reduce the likelihood of this happening but it's just becoming really inefficient. Any help? EDIT Hi guys thanks for the help, I've applied a couple of suggestions however I seem to be having trouble applying the isValid & isValid widgets to the script, these are the changes I've made so far import java.awt.Graphics; import org.osbot.script.Script; import org.osbot.script.ScriptManifest; import org.osbot.script.mouse.MinimapTileDestination; import org.osbot.script.rs2.map.Position; import org.osbot.script.rs2.model.RS2Object; import org.osbot.script.rs2.utility.Area; import org.osbot.script.rs2.model.NPC; import org.osbot.script.rs2.ui.RS2InterfaceChild; public int onLoop() throws InterruptedException { switch (getState()) { case BUY: ///FIND AND CLICK NPC final NPC Bartender = closestNPCForName("Bartender"); if(Bartender != null && myPlayer().getFacing() == null) { if(Bartender.interact("Talk-to", true)) { sleep(random(800, 1000)); if (inDialogue()) { continueDialogue(); sleep(random(800, 1000)); if (Bartender != null) if (interactWithInterface(230, 1, "Continue")); sleep(random(800, 1000)); if (inDialogue()) { continueDialogue(); sleep(random(800, 1000)); if (inDialogue()) { continueDialogue(); sleep(random(800, 1000)); if (Bartender != null) if (interactWithInterface(232, 3, "Continue")); sleep(random(800, 1000)); if (inDialogue()) { continueDialogue(); sleep(random(800, 1000)); if (inDialogue()) { continueDialogue(); sleep(random(700, 1100)); { } } } } } } } } break; /// end of buying stews How do I implement the isValid and isVisible into the script so I can remove the waits? also thanks a lot guys for the help so far =] Edited February 7, 2014 by blood1000 Link to comment Share on other sites More sharing options...
Isolate Posted January 18, 2014 Share Posted January 18, 2014 I've made a stew buyer, it purchases stews from the pub in seers and banks them, it works fairly well but as it's clicking through the chat talking to the bartender it sometimes misses a click then a load of error appear and it starts from the beginning clicking the bartender again and going through the chat again. How to I make it so that it tried a couple times trying to click continue (say if the chat lags) before restarting from the beginning and clicking the NPC? I've turned the speed down to reduce the likelihood of this happening but it's just becoming really inefficient. Any help? EDIT: I don't know if it's a problem with RS2 Child that it sometimes misses it or if it's lag, from watching it make the errors I can't really see why it misses some of the chat eww no, dont relly on sleeps EVER. add a isValid for the main widget an IsVisible for the children, so if any option is ever visible itl click through it Link to comment Share on other sites More sharing options...
Celeos Posted January 18, 2014 Share Posted January 18, 2014 Sleep after you have selected an option and only select an option if the respective interface child is visible. Also, get rid of the facing check. Remember to apply the java naming conventions for readability e.g. "Bartender" -> "bartender" ^_^ Link to comment Share on other sites More sharing options...
Swizzbeat Posted January 18, 2014 Share Posted January 18, 2014 As stated above NEVER really on sleeps. Instead you could do something like this to click through all the normal dialog boxes: if (inDialog()) { continueDialog(); } And then for the rest just check if the parent != null and the child element is being drawn. The script loops for a reason. 1 Link to comment Share on other sites More sharing options...
Satan111 Posted January 18, 2014 Share Posted January 18, 2014 As stated above NEVER really on sleeps. Instead you could do something like this to click through all the normal dialog boxes: if (inDialogue()) { continueDialogue(); } And then for the rest just check if the parent != null and the child element is being drawn. The script loops for a reason. Corrected 1 Link to comment Share on other sites More sharing options...
HelloPeeps Posted February 6, 2014 Author Share Posted February 6, 2014 (edited) Hi guys thanks for the help, I've applied a couple of suggestions however I seem to be having trouble applying the isValid & isValid widgets to the script, these are the changes I've made so far import java.awt.Graphics; import org.osbot.script.Script; import org.osbot.script.ScriptManifest; import org.osbot.script.mouse.MinimapTileDestination; import org.osbot.script.rs2.map.Position; import org.osbot.script.rs2.model.RS2Object; import org.osbot.script.rs2.utility.Area; import org.osbot.script.rs2.model.NPC; import org.osbot.script.rs2.ui.RS2InterfaceChild; public int onLoop() throws InterruptedException { switch (getState()) { case BUY: ///FIND AND CLICK NPC final NPC Bartender = closestNPCForName("Bartender"); if(Bartender != null && myPlayer().getFacing() == null) { if(Bartender.interact("Talk-to", true)) { sleep(random(800, 1000)); if (inDialogue()) { continueDialogue(); sleep(random(800, 1000)); if (Bartender != null) if (interactWithInterface(230, 1, "Continue")); sleep(random(800, 1000)); if (inDialogue()) { continueDialogue(); sleep(random(800, 1000)); if (inDialogue()) { continueDialogue(); sleep(random(800, 1000)); if (Bartender != null) if (interactWithInterface(232, 3, "Continue")); sleep(random(800, 1000)); if (inDialogue()) { continueDialogue(); sleep(random(800, 1000)); if (inDialogue()) { continueDialogue(); sleep(random(700, 1100)); { } } } } } } } } break; /// end of buying stews How do I implement the isValid and isVisible into the script so I can remove the waits? also thanks a lot guys for the help so far =] Edited February 7, 2014 by blood1000 Link to comment Share on other sites More sharing options...