Jump to content
View in the app

A better way to browse. Learn more.

OSBot :: 2007 OSRS Botting

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Help making my script more efficient?

Featured Replies

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

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

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"

 

^_^

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.

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

  • 3 weeks later...
  • Author

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

Guest
This topic is now closed to further replies.

Recently Browsing 0

  • No registered users viewing this page.

Account

Navigation

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.