October 4, 20169 yr java.lang.ArrayIndexOutOfBoundsException: -156 at org.osbot.rs07.api.Objects.get(ln:138) at ChefBot.onLoop(ChefBot.java:107) at org.osbot.rs07.event.ScriptExecutor$InternalExecutor.run(ao:83) at java.lang.Thread.run(Unknown Source) Offending line: List<RS2Object> doorTile = objects.get(3242, 3212); Am I doing something wrong or is this a bug?
October 5, 20169 yr Why are you making a list for one tile? Edit: okay, that's pretty weird. I never had to make a list for the position.. here's a quick mock-up. It worked for me. You always have to null check. Edited October 5, 20169 yr by Paradoxical
October 5, 20169 yr Author Why are you making a list for one tile? Edit: okay, that's pretty weird. I never had to make a list for the position.. here's a quick mock-up. It worked for me. You always have to null check. You didn't try my coordinates. I'm using the same code.. The list is the only way to get the object that that coords, there can be multiple objects per coordinate, up to 10. Edited October 5, 20169 yr by dmm_slaver
October 5, 20169 yr very strange... if you can't get this to work, maybe use something like this in the meantime: List<RS2Object> getObjectsAt(int x, int y) { List<RS2Object> objects = new ArrayList<>(); for(RS2Object o: objects.getAll()) { if(o != null && o.getPosition().getX() == x && o.getPosition().getY() == y) { objects.add(o); } } return objects; }
October 5, 20169 yr Why not use a filter? public RS2Object getObject(Position pos, String name) { return getObjects().closest(new Filter<RS2Object>() { @[member='Override'] public boolean match(RS2Object o) { return o != null && o.getName().equals(name)) && o.getPosition().equals(pos); } }); }
October 5, 20169 yr You didn't try my coordinates. I'm using the same code.. The list is the only way to get the object that that coords, there can be multiple objects per coordinate, up to 10. Well, I'm not exactly where you're at, so it's rather pointless to try your coords. Also, post more of the script. One line doesn't really help us in helping you much. Here's another filter if @@Khaleesi's didn't work out for you. Entity doors = objects.getAll().stream().filter(n -> n.getName().equals("Door") && n.getX() == 1234 && n.getY() == 1234 && n.getModel().equals(1234)).findFirst().get(); You can put in x, y coords, add in model number if it's a different object, or you can remove that part and simply change the getname string.
October 5, 20169 yr Author very strange... if you can't get this to work, maybe use something like this in the meantime: List<RS2Object> getObjectsAt(int x, int y) { List<RS2Object> objects = new ArrayList<>(); for(RS2Object o: objects.getAll()) { if(o != null && o.getPosition().getX() == x && o.getPosition().getY() == y) { objects.add(o); } } return objects; } I tried that, and the door is NOT in the list. I am assuming because of the same error that is causing the exception i experienced.
October 5, 20169 yr I tried that, and the door is NOT in the list. I am assuming because of the same error that is causing the exception i experienced. Did Khal's or my filter work?
October 5, 20169 yr According to the stacktrace the offending line is not in your code. If your code meets common sense standards such as following the API documentation on that method, what you encounter is an error in the API. The only error you can produce on your side with that code is by attempting to call it for a x-y pair which is not on the minimap. If this is not the case feel free to make a thread in the Client Bugs & Suggestions section.
Create an account or sign in to comment