Chazler Posted February 24, 2015 Share Posted February 24, 2015 So I'm trying to get the player to interact with a trapdoor when it does not have a bucket in its inventory to try out player interaction with entities. only Entity.closest(arg) gives an error simply because closest is not a valid method as seen below. Now my question is, how would one make a player interact with a certain entity in the way described above. Also I'm rather curious as to how one would implent the use of x and y coordinates so that there is no mistake, in the unlikley event of there being mutiple trapdoors, to which trapdoor the player has to interact with. Cheers, Chazler Quote Link to comment Share on other sites More sharing options...
Khaleesi Posted February 24, 2015 Share Posted February 24, 2015 (edited) So I'm trying to get the player to interact with a trapdoor when it does not have a bucket in its inventory to try out player interaction with entities. only Entity.closest(arg) gives an error simply because closest is not a valid method as seen below. Now my question is, how would one make a player interact with a certain entity in the way described above. Also I'm rather curious as to how one would implent the use of x and y coordinates so that there is no mistake, in the unlikley event of there being mutiple trapdoors, to which trapdoor the player has to interact with. Cheers, Chazler RS2Object trapdoor = objects.closest("Trapdoor"); A better way to do this is: if (!myPlayer().isMoving() && inventory.contains("Bucket")) { RS2Object trapdoor = objects.closest("Trapdoor"); if (trapdoor != null) if (trapdoor.isVisible()) trapdoor.interact("Climb-down"); else camera.toEntity(trapdoor); } If you want a trapdoor on a specific position you have to use the Filter. This can filter out everything you want. Example: if (!myPlayer().isMoving() && inventory.contains("Bucket")) { RS2Object trapdoor = objects.closest(new Filter<RS2Object>(){ @Override public boolean match(RS2Object object) { return object != null && object.getName().equals("Trapdoor") && object.getPosition().equals(new Position(0, 0, 0)); }}); if (trapdoor != null) if (trapdoor.isVisible()) trapdoor.interact("Climb-down"); else camera.toEntity(trapdoor); } Goodluck! Khaleesi Edited February 24, 2015 by Khaleesi 1 Quote Link to comment Share on other sites More sharing options...
Isolate Posted February 24, 2015 Share Posted February 24, 2015 So I'm trying to get the player to interact with a trapdoor when it does not have a bucket in its inventory to try out player interaction with entities. only Entity.closest(arg) gives an error simply because closest is not a valid method as seen below. Now my question is, how would one make a player interact with a certain entity in the way described above. Also I'm rather curious as to how one would implent the use of x and y coordinates so that there is no mistake, in the unlikley event of there being mutiple trapdoors, to which trapdoor the player has to interact with. Cheers, Chazler RS2Object thing = objects.closest("Blah"); Quote Link to comment Share on other sites More sharing options...
Chazler Posted February 24, 2015 Author Share Posted February 24, 2015 RS2Object trapdoor = objects.closest("Trapdoor"); A better way to do this is: if (!myPlayer().isMoving() && inventory.contains("Bucket")) { RS2Object trapdoor = objects.closest("Trapdoor"); if (trapdoor != null) if (trapdoor.isVisible()) trapdoor.interact("Climb-down"); else camera.toEntity(trapdoor); } If you want a trapdoor on a specific position you have to use the Filter. This can filter out everything you want. Exmaple: if (!myPlayer().isMoving() && inventory.contains("Bucket")) { RS2Object trapdoor = objects.closest(new Filter<RS2Object>(){ @Override public boolean match(RS2Object object) { return object != null && object.getName().equals("Trapdoor") && object.getPosition().equals(new Position(0, 0, 0)); }}); if (trapdoor != null) if (trapdoor.isVisible()) trapdoor.interact("Climb-down"); else camera.toEntity(trapdoor); } Goodluck! Khaleesi Quick and on the spot as always, much obliged! Quote Link to comment Share on other sites More sharing options...
Botre Posted February 24, 2015 Share Posted February 24, 2015 pls use getObjects() instead of objects. Quote Link to comment Share on other sites More sharing options...
VladBots Posted February 24, 2015 Share Posted February 24, 2015 pls use braces Quote Link to comment Share on other sites More sharing options...
Joseph Posted February 24, 2015 Share Posted February 24, 2015 (edited) pls use braces pls use getObjects() instead of objects.make us. I requested alek for a position filter class so check that out op. Edited February 24, 2015 by josedpay Quote Link to comment Share on other sites More sharing options...
VladBots Posted February 24, 2015 Share Posted February 24, 2015 make us. I requested alek for a position filter class so check that out op. your code gains readability Quote Link to comment Share on other sites More sharing options...
Botre Posted February 24, 2015 Share Posted February 24, 2015 make us. I requested alek for a position filter class so check that out op. We already have a pretty flexible filter class :@ Quote Link to comment Share on other sites More sharing options...
Joseph Posted February 24, 2015 Share Posted February 24, 2015 We already have a pretty flexible filter class :@ i know i love it, but just know we never had the position filter until now http://osbot.org/forum/topic/65624-suggesting-another-filter/ Quote Link to comment Share on other sites More sharing options...
Botre Posted February 24, 2015 Share Posted February 24, 2015 i know i love it, but just know we never had the position filter until now http://osbot.org/forum/topic/65624-suggesting-another-filter/ Cmoooon man public Filter<RS2Object> pls(Position lel) { Filter<RS2Object> wat= new Filter<RS2Object>() { @Override public boolean match(RS2Object mald) { return !mald.getPosition().equals(lel); } }; return wat; } Quote Link to comment Share on other sites More sharing options...
Joseph Posted February 24, 2015 Share Posted February 24, 2015 (edited) Cmoooon man public Filter<RS2Object> pls(Position lel) { Filter<RS2Object> wat= new Filter<RS2Object>() { @Override public boolean match(RS2Object mald) { return !mald.getPosition().equals(lel); } }; return wat; } you see all that code you have to type up. I got tried of doing that. When now we can simply do getObjects().closest(new PositionFilter(position)); edit: i know its easy to create a simple method like that. I simply request for the filter because we have many different filters available. It wasnt there when i look at it. It will be handy to others especially the nubs (like me ) and i mean there is a PolygonArea filter (which the PolygonArea class was just recently released) and not a position filter. Which btw in OSB1 there use to be like a method to get an entity using a position. Edited February 24, 2015 by josedpay 1 Quote Link to comment Share on other sites More sharing options...
Botre Posted February 24, 2015 Share Posted February 24, 2015 Yeah, a more beginner-friendly API isn't a bad thing per se. And I suppose it takes Alek like 5 seconds to write methods like that. No reason to be grumpy I guess *flies away* Quote Link to comment Share on other sites More sharing options...
Alek Posted February 24, 2015 Share Posted February 24, 2015 Uhh, why are we still discussing the PositionFilter? It's already implemented: http://osbot.org/api/org/osbot/rs07/api/filter/PositionFilter.html Quote Link to comment Share on other sites More sharing options...
Joseph Posted February 25, 2015 Share Posted February 25, 2015 Uhh, why are we still discussing the PositionFilter? It's already implemented: http://osbot.org/api/org/osbot/rs07/api/filter/PositionFilter.html i know thats what ive been saying Quote Link to comment Share on other sites More sharing options...