Jump to content

Why is there no item.interact()


Kenneh

Recommended Posts

I understand that there is one in the inventory class, but that's pretty stupid considering that all the entities have interaction methods.

 

package org.kenneh.scripts;

import org.kenneh.api.script.PollingScript;
import org.osbot.script.ScriptManifest;
import org.osbot.script.rs2.model.Item;
import org.osbot.script.rs2.model.NPC;
import org.osbot.script.rs2.model.RS2Object;

import java.awt.*;

/**
 * Created by Kenneth on 5/1/2014.
 */

@ScriptManifest(
        name = "Test Script",
        author = "Kenneh",
        info = "For debugging purposes",
        version = 0.1
)
public class TestScript extends PollingScript {

    @Override
    public void onPaint(Graphics graphics) {
        final Graphics2D graphics2D = (Graphics2D) graphics;
        for(NPC npc : ctx.npcs.refresh().name("Chicken")) {
            if(npc != null && npc.isVisible()) graphics2D.draw(npc.getPosition().getPolygon(ctx.script.bot));
            try {
                npc.interact("asdfasdf");
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }
        for(RS2Object obj : ctx.objects.refresh().name("Sack")) {
            if(obj != null && obj.isVisible()) graphics2D.draw(obj.getPosition().getPolygon(ctx.script.bot));
            try {
                obj.interact("asdfasdf");
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }
        for(Item item : ctx.inventory.refresh().name("Feather")) {
            item.interact("asdfasdf"); // Okay, there is literally no reason for this not to exist.
        }
    }

    @Override
    public void start() {

    }

    @Override
    public int poll() {
        return 50;
    }
}
Link to comment
Share on other sites

Yeah, inefficient too. I hate the idea of needing to iterate twice to validate and interact, but there seems to be no other way because Item and ItemDefinition hold neither the index of the item or any methods that return the widget child the item belongs to. And that's why I like how I structured my shop api. smile.png

Edited by liverare
Link to comment
Share on other sites

How to know when someone didn't read the thread wink.png

 

Hopefully this will be fixed in v2.

 

Edit;

There isn't even an interactWithItem(), the Item class is literally useless

 

f8MRkXR.png

Sorry!

 

But I wouldn't say the Item class is useless. I just think that the Item class should at least be able to store the RSInterface child, which you could then interact with.

Yeah, inefficient too. I hate the idea of needing to iterate twice to validate and interact, but there seems to be no other way because Item and ItemDefinition hold neither the index of the item or any methods that return the widget child the item belongs to. And that's why I like how I structured my shop api. smile.png

Yo! Your solution may be to use 

8uSDu.png

and

8uSEt.png

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...