Joseph Posted March 24, 2014 Share Posted March 24, 2014 (edited) How to initialize: LootingBag lootingBag; @Override public void onStart() { lootingBag = new LootingBag(this); } Picture: Snippet: import java.awt.Point; import java.awt.Rectangle; import org.osbot.script.Script; import org.osbot.script.rs2.model.Item; import org.osbot.script.rs2.ui.Tab; public class LootingBag { private Script script; //Important: private int parent = 81; private int close = 2; private int items = 7; private int bankDepositParent = 15; private int bankDepositChild = 5; //For Slots: private int startWidth = 558; private int startHeight = 231; private int width = 33; private int height = 30; public LootingBag(Script script) { this.script = script; } public boolean isOpen() { return script.client.getInterface(parent)!=null; } public boolean close() throws InterruptedException { if (isOpen() && script.client.getInterface(parent).getChild(close)!=null) return script.client.getInterface(parent).getChild(close).interact(); return false; } public Item get(int id) { if (isOpen()) for (Item item: getItems()) if (item!=null && item.getId() == id) return item; return null; } public Item get(String name) { if (isOpen()) for (Item item: getItems()) if (item!=null && item.getName().equalsIgnoreCase(name)) return item; return null; } public Item[] getItems() { if (isOpen()) if (script.client.getInterface(parent).getChild(items)!=null) return script.client.getInterface(parent).getItems(items); return null; } public boolean contains(Item item) { if (isOpen()){ for (Item i: getItems()) if (i!=null && i.getId()!=-1) return i.getId() == item.getId(); } return false; } public boolean isEmpty() { return getTotal() > 0 ? false: true; } public int getAmount(Item item) { if (isOpen()) return item.getAmount(); return -1; } public int getTotal() { int total = 0; if (isOpen()){ for (Item item: getItems()) if (item!=null && item.getId() != -1) total++; return total; } return -1; } public int getSlot(Item item) { if (isOpen() && contains(item)) { for (int i =0; i<getItems().length; i++) { if (getItems()[i] !=null) if (getItems()[i].equals(item)) return i; } } return -1; } public Point getPoint(int slot) { int column = slot / 4; int row = slot % 4; int x = (int) (this.startWidth + (row * this.width) +(row * 10)); int y = (int) (this.startHeight + (column * this.height) +(column * 3)); return new Point(x, y); } public Rectangle getRectangle(int slot) { Point p = getPoint(slot); return new Rectangle(p.x, p.y, this.width, this.height); } public boolean bankDepositOpen() { return script.client.getInterface(this.bankDepositParent)!=null; } //will finish up public boolean emptyBagIntoBank() { if (script.client.getBank().isOpen()){ } return false; } //will finish up public boolean interact(String action) throws InterruptedException { if (!this.isOpen()) if (!script.currentTab().equals(Tab.INVENTORY)) this.script.openTab(Tab.INVENTORY); else return script.client.getInventory().interactWithName("Looting Bag", action); return true; } /* i removed the deposit enum going to create a new interaction method public boolean depositIntoBag(int id, Deposit deposit, int amount) throws InterruptedException { if (isOpen() && contains(id)) { Rectangle rec = getRectangle(getSlot(id)); if (rec !=null) { if (!deposit.equals(Deposit.STORE_X)) return script.selectOption(null, new RectangleDestination(rec), deposit.toString()); else{ script.selectOption(null, new RectangleDestination(rec), deposit.toString()); script.sleep(2000); script.type(Integer.toString(amount)); return true; } } } return false; } */ } Edited April 27, 2014 by josedpay Link to comment Share on other sites More sharing options...
Kenneh Posted March 25, 2014 Share Posted March 25, 2014 code looks shitty as fuck. btw what's a looting bag and how do you get one? 2 Link to comment Share on other sites More sharing options...
Botre Posted March 25, 2014 Share Posted March 25, 2014 love your snippets ;) 1 Link to comment Share on other sites More sharing options...
GoldenGates Posted March 25, 2014 Share Posted March 25, 2014 code looks shitty as fuck. btw what's a looting bag and how do you get one? At least he did release something which will function. Proper criticism is better than that. :P 1 Link to comment Share on other sites More sharing options...
Joseph Posted March 25, 2014 Author Share Posted March 25, 2014 code looks shitty as fuck. btw what's a looting bag and how do you get one? If you ain't going to give positive criticism then what about fuck off, you ungrateful prick And a looting bag is a bag you receive in the wildy. The bag gives you 28 more inventory space. Only works In the wild, any npc in the wild drop them. Anything you put in the bag can't be removed unless you deposit them in the bank. Link to comment Share on other sites More sharing options...
Kenneh Posted March 25, 2014 Share Posted March 25, 2014 If you ain't going to give positive criticism then what about fuck off, you ungrateful prick And a looting bag is a bag you receive in the wildy. The bag gives you 28 more inventory space. Only works In the wild, any npc in the wild drop them. Anything you put in the bag can't be removed unless you deposit them in the bank. You're calling me an ungrateful prick for something I'm never going to use. I help people out on this forum from time to time but it's hardly worth it. This community isn't really advancing so why bother. Link to comment Share on other sites More sharing options...
Swizzbeat Posted March 25, 2014 Share Posted March 25, 2014 You're calling me an ungrateful prick for something I'm never going to use. I help people out on this forum from time to time but it's hardly worth it. This community isn't really advancing so why bother. Every time I see you post you act like you're some Java wizard that knows absolutely everything. I'm not saying you're not knowledgeable, but stop trying to act like a hardass on an internet forum. Link to comment Share on other sites More sharing options...
Dog_ Posted March 25, 2014 Share Posted March 25, 2014 Every time I see you post you act like you're some Java wizard that knows absolutely everything. I'm not saying you're not knowledgeable, but stop trying to act like a hardass on an internet forum.isnt that what forums are used for?On topic, good job josedpay - I'm sure some people will find this useful 2 Link to comment Share on other sites More sharing options...
GoldenGates Posted March 25, 2014 Share Posted March 25, 2014 Every time I see you post you act like you're some Java wizard that knows absolutely everything. I'm not saying you're not knowledgeable, but stop trying to act like a hardass on an internet forum. Respect the Kenneh. Kenneh is God #3. Link to comment Share on other sites More sharing options...
Kenneh Posted March 25, 2014 Share Posted March 25, 2014 Every time I see you post you act like you're some Java wizard that knows absolutely everything. I'm not saying you're not knowledgeable, but stop trying to act like a hardass on an internet forum. I try. Like, I really try sometimes. I considered coming to osb and making scripts but every time I do, I remember that the API just terrible and I literally have to re-write everything myself. I get about halfway done with writing some usable API I realize that it's just not worth it and trash my project. Respect the Kenneh. Kenneh is God #3. Who are one and two? I shall kill them! Link to comment Share on other sites More sharing options...
GoldenGates Posted March 25, 2014 Share Posted March 25, 2014 I try. Like, I really try sometimes. I considered coming to osb and making scripts but every time I do, I remember that the API just terrible and I literally have to re-write everything myself. I get about halfway done with writing some usable API I realize that it's just not worth it and trash my project. Who are one and two? I shall kill them! Harrynoob and I. Link to comment Share on other sites More sharing options...
Dog_ Posted March 25, 2014 Share Posted March 25, 2014 Harrynoob and I.what the fuck where am i Link to comment Share on other sites More sharing options...
GoldenGates Posted March 25, 2014 Share Posted March 25, 2014 what the fuck where am i You were 4. .-. harry and kenneh were my inspirations as a child. You're just a dog_. Link to comment Share on other sites More sharing options...
Dog_ Posted March 25, 2014 Share Posted March 25, 2014 You were 4. .-. harry and kenneh were my inspirations as a child. You're just a dog_.I was expecting 1 Link to comment Share on other sites More sharing options...
Kenneh Posted March 25, 2014 Share Posted March 25, 2014 harrynoob is the best 1 Link to comment Share on other sites More sharing options...