Skip 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.

API suggestions

Featured Replies

Ok, I feel like a few things are missing, as well as ways current methods could be improved. This is a Beta and I feel these are useful suggestions. I will be updating the thread with more suggestions as I come across anything that could be improved. Feel free to use any of my code from this thread in your own scripts etc (Credit would be appreciated).

 


Closest entity methods:
Overall, it would be more benificial to loop through the entities like this:

for (RS2Object o : client.getCurrentRegion().getObjects()) {

rather than (what I presume is) this: Spoke to Laz about this, the original method only returns "reachable" objects.

for (RS2Object o : client.getObjects()) {

as the latter seems to be buggy (for example, in my Fight Caves script it seems to almost always return null for the entrance).

I also would like to add that a method for returning the closest ground items is also abscent in the API. Here is a method which I quickly wrote:

private RS2Object getClosestObject(int id) {    RS2Object o = null;    for (RS2Object obj : client.getCurrentRegion().getObjects())	    if (obj != null && obj.getId() != null && obj.getId() == id)		    if (o == null || distance(obj) < distance(o))			    o = obj;    return o;}

 

Another useful feature (paired with the closestEntity methods) is the use of Filters, which would be useful in most scripts. This could also be easily achieved by creating an abstract class:

interface Filter<T> {    public boolean accept(T element);}

and could be implemented, for example, with

GroundItem closestGroundItem(Filter f) {    GroundItem item = null;    for (GroundItem i : client.getCurrentRegion().getItems())        if (i != null) if (item == null && f.accept(i))        item = g;    return item;}

and could be called with

GroundItem getCoins() {    return closestGroundItem(new Filter<GroundItem>() {         @Override boolean accept(GroundItem item) {            return item.getId() == 996;        }    });}

This is all I have now, but as stated above, I shall add more as I see fit.

 

Interaction methods:
It is likely to have been mentioned before, but I think it would be a good move to have interact with entities using a method more along the lines of

entity.interact(String, boolean);

as opposed to the current

selectEntityOption(Entity, boolean)

as it has a more logical look to it (in my opinion). At the same time, I would also like mention another important method to add would be said interacton methods for inventory items and possibly widgets (RSInterface/RSInterfaceChild) too.


 

Distance calculation methods:
Similar to above, not much to be improved but for calculating distance between entities it would be more convenient to have the method

entity.distance(Entity)

instead of

entity.getPosition().distance(Entity.getPosition())

or just have a script-level method such as

distance(Entity, Entity)

 

 

Widget-related methods:

This is another thing I find is missing, it would also be useful to be able to "search" for widgets using a String argument as well as a method to click continue in dialogue. Here is some code I quickly wrote (under the assumption that RS2InterfaceChild.getMessage() returns the text on the widget)

public boolean clickContinue() {    RS2InterfaceChild c = getChildWithText("continue");    if (c != null)        return c.click();    return false;}public RS2InterfaceChild getChildWithText(String text) {    for (RS2Interface i : client.interfaces)        for (RS2InterfaceChild c : i.getChildren())            if (c.getMessage().contains(text))                return c;    return null;}public RS2InterfaceChild getChildWithText(String... text) {    for (RS2Interface i : client.interfaces)        for (RS2InterfaceChild c : i.getChildren())            for (String s : text)                if (c.getMessage().contains(s))                    return c;    return null;}

Edited by Fuz

It's impossible for

 

"for (RS2Object o : client.getObjects()) {" 

 

to occur since the client only loops through objects that are in the game since it's impossible to load all game objects in the world so we already know that we're looping via the region we're in.

 

The Filter has been suggested already as well, hopefully it's also added on to the API

  • Author

Bump.
Related suggestion: Bumping feature so you dont have to post if you're the OP.

  • Author

OH GOD GIVE THIS GUY A MEDAL

I'm having a hard time telling whether that was sarcasm or praise.

Guest
This topic is now closed to further replies.

Recently Browsing 0

  • No registered users viewing this page.

Account

Navigation

Search

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.