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.

OSBot Helper - Making script development easier

Featured Replies

Don't know if this is in the right section, but it's related to script development.

 

 

If you don't want to read all of my blabbering, you can find the code here (criticism/feedback appriciated, sorry for the lack of code, im working on it still): https://github.com/lare96/osbot-helper

 

 

Introduction

 

While writing scripts and attempting to reteach myself everything I noticed that I had been rewriting the same code and using the same utilities throughout virtually every project. This was apparent most specifically with the event state system, that I was copying and pasting from script to script. So I thought I'd write an open source API consisting of all of these things I was using in all of my scripts anyway, to save time.

 

 

Why this is useful

 

Not going to go too too deep into details, if you're really interested just click the link to the repository at the top of the thread and check it out smile.png

 

  • Has support for event state "priorities", more important event states can be validated and executed before less important ones.
  • Has support for randomized sleeping times, that can be between customized intervals of your choice.
  • Has "fallback" event support (an event that is executed when no other event can be validated), and you can set the fallback event to the event of your choice.
  • Support for attaching an Object to an EventManager (such as your script instance), that can then be therefore accessed through your event states (through the "context" parameter).
  • Well designed and very easy to use, especially for AIO scripts (fletching; for example, you can have several different event manager instances for each fletching activity)
  • Support for "event loop" types: static (maximum one event executed per cycle, the highest priority event which is valid is executed) and dynamic (all events which are valid are executed regardless).

And lots of other cool features even unrelated to the event system. There's a few utility classes worth looking at too.

 

 

Usage

 

An example of how the EventManager is utilized...

@ScriptManifest(name = "ScriptExample", author = "lare96", version = 1.0, info = "Script example.", logo = "")
public final class ScriptExample extends Script {

    private final EventManager manager = new EventManager();

    @Override
    public void onStart() {
        ...
        
        manager.submit(new EatFoodEvent(EventPriority.HIGH));
        manager.submit(new CombatEvent());
        manager.submit(new MoveCameraEvent(EventPriority.LOW));
        manager.submit(new LootEvent());
        manager.setAttachment(this);
    }

    @Override
    public int onLoop() {
        ...
        
        return manager.executeHook();
    }

    @Override
    public void onPaint(Graphics2D g) {
        ...
 
        g.drawString("Time Running: " +  manager.getTimeRunning(), 7, 265);

        ...
    }
}

An example of how to create an event state...

// Lets say in theory this event state logs our player out if their health is below a certain amount.
public final class LogoutEvent extends Event {

    public LogoutEvent() {

        // This is a very important event, so we'd give it max priority.
        super(EventPriority.HIGH);
    }

    @Override
    public boolean validate(EventManager context) {
        ScriptExample s = (ScriptExample) context.getAttachment();

        // Check if the player's health is below 10 here...
        ...
        
        return ...;
    }

    @Override
    public void execute(EventManager context) {
        ScriptExample s = (ScriptExample) context.getAttachment();
        
        // And if the player's health is, log us out.
        ...
    }
}

Download

 

Haven't bothered to export this as JAR file yet, because it's not completed. I'm going to keep developing this as I get more familiar with scripting and add on to it with more features.

 

Once again, you can find the source code here: https://github.com/lare96/osbot-helper

 

Any and all criticism is appreciated, be harsh!!!

Edited by lare96

protip: comparing ints is bad for making priority controllers.  otherwise looks helpful to new people (although i think anyone that could use this could also write their own) because all this is is a node system with int comparing for priority

 

 

edit:  you are actually using a comparator so i guess its ok to use ints, although i happen to do it a little differently

Edited by Novak

  • Author

protip: comparing ints is bad for making priority controllers.  otherwise looks helpful to new people (although i think anyone that could use this could also write their own) because all this is is a node system with int comparing for priority

 

 

edit:  you are actually using a comparator so i guess its ok to use ints, although i happen to do it a little differently

 

The Event class implements Comparable so it's the natural ordering and I used Collections#reverseOrder so events with a higher priority come first.

 

Also I know right now it's just an event-state system but I plan on adding more to it as I write more scripts :)

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.