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.

Handle event based on interaction with item?

Featured Replies

EDIT: this question has been resolved and spoiler'd.

I instead used  getClient().getTooltip()  to get the "up-text" (hover text, in the top left) and parsed out the item name.

 

Original question is below:

I'm working on an auto-drop script just for personal use, and I'm trying to work out how I want to select which items in my inventory to drop.  Currently, my script listens for Ctrl-F, and selects the item that's selected in the inventory, if one is selected.  In my opinion, this feels clunky.
 
Is it possible to listen for an interaction between the player and an item, and to handle an event based on the interaction?  I'm thinking of being able to hold Ctrl and "examine" an item in the inventory to select it, rather than toggling a state (selecting an item), pressing a hotkey, and then toggling again (deselecting the item).
 
I had the idea to keep track of each different item in the inventory (i.e. HashMap<String, ItemDefinition>), storing its "examine" text, and listening for a message similar to one that's stored, but as far as I can tell that would be massively inefficient and a pain to keep up with.
 
In other words, is there a method that would perform as if  onInteract(ItemInteractEvent e)?  TIA!

 

For reference, my handling code now (spoiler'd to prevent massive post)

 

DropAll.java (subclass of Script)

@Override
public void onStart() {
    // add custom key listener
    this.getBot().getCanvas().addKeyListener(new com.github.chaoticweg.DropAll.KeyListener());
}

// ...

public void selectNewItem() {
    String newItem = this.getInventory().getSelectedItemName();
    if (newItem == null) newItem = "";

    selectedItem = newItem; // selectedItem declared above in class
    this.getInventory().deselectItem();
}

KeyListener.java (implements java.awt.event.KeyListener)

private boolean armed = false;
private DropAll script;

public KeyListener(DropAll script) {
    this.script = script;
}

@Override
public void keyTyped(KeyEvent e) {
    // do nothing
}

@Override
public void keyPressed(KeyEvent e) {
    if (e.getKeyCode() == KeyEvent.VK_CONTROL)
        armed = true;
    if (e.getKeyCode() == KeyEvent.VK_F)
        script.selectNewItem();
}

@Override
public void keyReleased(KeyEvent e) {
    if (e.getKeyCode() == KeyEvent.VK_CONTROL)
        armed = false;
}

Edited by x3chaos

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.