Solzhenitsyn Posted August 1, 2016 Share Posted August 1, 2016 (edited) getSlot public int getSlot(Filter<Item>... filter) Gets the slot for the first item matched after filtering the container. Parameters: filter - The filter(s). Returns: The first slot matched. http://osbot.org/api/org/osbot/rs07/api/util/ItemContainer.html#getItem-org.osbot.rs07.api.filter.Filter...- 1) Will the method return 0 if no item is found? 2) What orientation? Is the upper left slot 1, upper right 4, lower left 24, lower right 28? Edited August 1, 2016 by FuckingAshole Quote Link to comment Share on other sites More sharing options...
Pseudo Posted August 1, 2016 Share Posted August 1, 2016 Iirc the first slot would be at index 0, then it progresses through rows then columns, so 0-1-2-3 would be the uppermost four slots, in order. I may be wrong, though. Quote Link to comment Share on other sites More sharing options...
Solzhenitsyn Posted August 1, 2016 Author Share Posted August 1, 2016 It's returning an int, not a data structure. Quote Link to comment Share on other sites More sharing options...
Flamezzz Posted August 1, 2016 Share Posted August 1, 2016 You can find out yourself 1 Quote Link to comment Share on other sites More sharing options...
Khaleesi Posted August 1, 2016 Share Posted August 1, 2016 1) Probably -1 (Why not tets yourself quickly?) 2) Slots are counted per row ... 0 1 2 3 4 5 6 7 ... 1 Quote Link to comment Share on other sites More sharing options...
Explv Posted August 1, 2016 Share Posted August 1, 2016 (edited) This is something you could have easily figured out yourself by doing a small amount of testing. The definition of getSlot() looks like: public int getSlot(final Item item) { if(item == null) { return -1; } else { Item[] items = getInventory().getItems(); // returns an array of size 28 for(int i = 0; i < items.length; i++) { if(items[i] != null && items[i].equals(item)) { return i; } } return -1; } } As you can see, if the item is not found it returns -1. Otherwise it returns a value from 0 (inclusive) to 28 (exclusive). 0 is the top left slot, 27 is the bottom right slot. The index increments from left to right: 0 1 2 3 4 5 6 7 8 9 10 11 etc. Edited August 1, 2016 by Explv 1 Quote Link to comment Share on other sites More sharing options...
Solzhenitsyn Posted August 1, 2016 Author Share Posted August 1, 2016 (edited) This is something you could have easily figured out yourself by doing a small amount of testing. The definition of getSlot() looks like: public int getSlot(final Item item) { if(item == null) { return -1; } else { Item[] items = getInventory().getItems(); // returns an array of size 28 for(int i = 0; i < items.length; i++) { if(items[i] != null && items[i].equals(item)) { return i; } } return -1; } } As you can see, if the item is not found it returns -1. Otherwise it returns a value from 0 (inclusive) to 28 (exclusive). 0 is the top left slot, 27 is the bottom right slot. The index increments from left to right: 0 1 2 3 4 5 6 7 8 9 10 11 etc. How did you find the source for the function? I have a hard time understanding API, but now that I know that getItems returns an array of the contents of each slot (I was under the impression it returned an array of only the items contained) I understand perfectly. Thanks for your post. Edited August 1, 2016 by FuckingAshole Quote Link to comment Share on other sites More sharing options...
Explv Posted August 1, 2016 Share Posted August 1, 2016 (edited) How did you find the source for the function? I have a hard time understanding API The source code is heavily obfuscated, so I wouldn't bother trying to read it. In terms of the getSlot() method, as the API does not specify anything else, it is safe to assume that it would return an index from 0 to the inventory size. Most methods that return some form of index would start at 0, and you know that the inventory has 28 slots. As a valid index would always be positive, -1 is typically used to indicate that a valid index could not be found, you will find this everywhere in programming. Regarding the ordering, you can't know for sure as it's not in the API, but most people would assume left to right in rows. If you don't know exactly how something works, just write a little test and you'll find out. Edited August 1, 2016 by Explv Quote Link to comment Share on other sites More sharing options...
Pseudo Posted August 1, 2016 Share Posted August 1, 2016 It's returning an int, not a data structure. I didn't say any different, I merely answered your question young sir. Quote Link to comment Share on other sites More sharing options...
liverare Posted August 1, 2016 Share Posted August 1, 2016 (edited) It simply returns the first index of a slot which is found to match your filtering criteria. getSlot is a pretty misleading method name tbh, when it's purpose is almost exactly the same as indexOf. A more meaningful name would be getFirstSlotIndexOf, since there's a filter for a parameter and only one value gets returned. #indexOf default return value is -1, because 0 is a valid array index. With the value being -1, the programmer can use logic to determine if a slot had actually been returned, before attempting to access said slot one. The orientation of slots is, I'm guessing, however Jagex dictate it to be, since all the widgets are designed by them. Khaleesi mentioned the orientation of the inventory slots. Edited August 1, 2016 by liverare Quote Link to comment Share on other sites More sharing options...
Alek Posted August 1, 2016 Share Posted August 1, 2016 The API docs are very useful when scripting. http://osbot.org/api/org/osbot/rs07/api/util/ItemContainer.html public int getSlot(Item item) Gets the slot for the specified item. Note: The item is matched based on id and amount only. Parameters: item - The item to match. Returns: The slot of the item. If no item is found, -1 is returned. 2 Quote Link to comment Share on other sites More sharing options...