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.

T12: Selection API update (with snippet)

Featured Replies

c62c2a31744f26cbf4938f376e342d8b.png

@ScriptManifest(author = "Botre", info = "", logo = "", name = "Selection Listener Example", version = 0)
public class SelectionListenerExample extends Script implements SelectionListener<NPC> {

	private Sapi sapi;
	
	@Override
	public void onStart() throws InterruptedException {
		super.onStart();
		sapi = new Sapi(this);
		sapi.registerMouseAdapter();
		sapi.setSelector(Module.NPC);
		sapi.getNpcSelector().getSelectionListeners().add(this);
	}
	
	@Override
	public int onLoop() throws InterruptedException {
		//...
		return 500;
	}
	
	@Override
	public void onPaint(Graphics2D g2d) {
		super.onPaint(g2d);
		for (NPC npc : sapi.getNpcSelector().getSelection()) {
			Painter.defaultEntity().paint(g2d, this, npc);
		}
	}
	
	@Override
	public void onExit() throws InterruptedException {
		sapi.unregisterMouseAdapter();
		super.onExit();
	}

	@Override
	public void onSelection(List<NPC> selection) {
		for (NPC npc : selection) {
			if(npc != null) {
				log("Selected npc with name: " + npc.getName());
				if(npc.getActions() == null) continue;
				log("This npc has the following actions:");
				for (String action : npc.getActions()) {
					log("\t" + action);
				}
			}
		}
	}

}

Edited by Botre

Shoudln't one of those actions be 'Walk here'? 

Also, why are you displaying 3 'null's

 

Other than that it looks pretty intersting

Edited by Zappster

  • Author

Shoudln't one of those actions be 'Walk here'? 

Also, why are you displaying 3 'null's

 

Other than that it looks pretty intersting

 

"Walk-here" is actually a tile action, not an entity action.

I just didn't bother filtering the null actions out since this is just a testing / demonstration snippet, but since you're my special friend:

if(action == null) continue;
log("\t" + action);

Create an account or sign in to comment

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.