Kenneh Posted May 1, 2014 Share Posted May 1, 2014 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 More sharing options...
Deffiliate Posted May 1, 2014 Share Posted May 1, 2014 http://osbot.org/api/org/osbot/script/rs2/ui/Inventory.html Look at interactWithName(), id etc. Link to comment Share on other sites More sharing options...
FearMe Posted May 1, 2014 Share Posted May 1, 2014 I actually don't know why this doesn't exist when there's ItemDefinition. I've always found the Item class to be rather useless, lol. Link to comment Share on other sites More sharing options...
liverare Posted May 1, 2014 Share Posted May 1, 2014 (edited) 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. Edited May 1, 2014 by liverare Link to comment Share on other sites More sharing options...
Kenneh Posted May 1, 2014 Author Share Posted May 1, 2014 (edited) http://osbot.org/api/org/osbot/script/rs2/ui/Inventory.html Look at interactWithName(), id etc. How to know when someone didn't read the thread Hopefully this will be fixed in v2. Edit; There isn't even an interactWithItem(), the Item class is literally useless Edited May 1, 2014 by Kenneh 1 Link to comment Share on other sites More sharing options...
Deffiliate Posted May 1, 2014 Share Posted May 1, 2014 How to know when someone didn't read the thread Hopefully this will be fixed in v2. Edit; There isn't even an interactWithItem(), the Item class is literally useless 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. Yo! Your solution may be to use and Link to comment Share on other sites More sharing options...
Dog_ Posted May 1, 2014 Share Posted May 1, 2014 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.The inventory only has one Interface child. Link to comment Share on other sites More sharing options...
Deffiliate Posted May 1, 2014 Share Posted May 1, 2014 The inventory only has one Interface child. Which has multiple grandchildren for each Item.... >.> Link to comment Share on other sites More sharing options...
Dog_ Posted May 1, 2014 Share Posted May 1, 2014 (edited) Which has multiple grandchildren for each Item.... >.>Incorrect, the InterfaceChild is 149, 0 and that child alone contains all the items. It's the same with equipment, store and deposit box. Bank and trade screen do have grandchildren for items though. Edited May 1, 2014 by Rawr 2 Link to comment Share on other sites More sharing options...
liverare Posted May 1, 2014 Share Posted May 1, 2014 [ . . .]] Yo! Your solution may be to use and I suppose that would be a fine substitute. But I'd still want the Item class to store the item's slot index and have interaction method. Link to comment Share on other sites More sharing options...