Jump to content

Help making my script more efficient?


HelloPeeps

Recommended Posts

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? smile.png

 

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 by blood1000
Link to comment
Share on other sites

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? smile.png

 

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

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 :)

  • Like 1
Link to comment
Share on other sites

  • 3 weeks later...

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 by blood1000
Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...