February 24, 201510 yr 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
February 24, 201510 yr 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, 201510 yr by Khaleesi
February 24, 201510 yr 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");
February 24, 201510 yr Author 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!
February 24, 201510 yr 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, 201510 yr by josedpay
February 24, 201510 yr make us. I requested alek for a position filter class so check that out op. your code gains readability
February 24, 201510 yr make us. I requested alek for a position filter class so check that out op. We already have a pretty flexible filter class :@
February 24, 201510 yr 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/
February 24, 201510 yr 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; }
February 24, 201510 yr 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, 201510 yr by josedpay
February 24, 201510 yr 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*
February 24, 201510 yr Uhh, why are we still discussing the PositionFilter? It's already implemented: http://osbot.org/api/org/osbot/rs07/api/filter/PositionFilter.html
February 25, 201510 yr 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
Create an account or sign in to comment