frozen8 Posted July 28, 2015 Share Posted July 28, 2015 Is there a reason why this is always return 0 or 1 (0 of there's none and 1 if there's any) It's not boolean it's suppose to be integer. inventory.getItem("Jug of water").getAmount() Also is there a way to Face the camera to a NPC? Thanks for the help! Quote Link to comment Share on other sites More sharing options...
Bobrocket Posted July 28, 2015 Share Posted July 28, 2015 Facing camera to NPC: getCamera().toEntity(NPC); Is your jug of water noted? inventory.getItem() returns the first found item, so you could be getting an unnoted one (hence getting 1), and none should very well be 0 as there are 0 jugs. 1 Quote Link to comment Share on other sites More sharing options...
frozen8 Posted July 28, 2015 Author Share Posted July 28, 2015 Facing camera to NPC: getCamera().toEntity(NPC); Is your jug of water noted? inventory.getItem() returns the first found item, so you could be getting an unnoted one (hence getting 1), and none should very well be 0 as there are 0 jugs. No they are not noted. I'm trying to get the number of Jug of water in my inventory. Quote Link to comment Share on other sites More sharing options...
Bobrocket Posted July 28, 2015 Share Posted July 28, 2015 No they are not noted. I'm trying to get the number of Jug of water in my inventory. The API states that #getItem() returns a type of item. The method you want is ItemContainer#getAmount(String ... items) Usage: int amt = getInventory().getAmount("Jug of Water"); 2 Quote Link to comment Share on other sites More sharing options...
frozen8 Posted July 28, 2015 Author Share Posted July 28, 2015 (edited) The API states that #getItem() returns a type of item. The method you want is ItemContainer#getAmount(String ... items) Usage: int amt = getInventory().getAmount("Jug of Water"); Thanks it's working! Also I'm having one last issue with the door. My current code to handle the door is this: if(!myPlayer().isMoving()) { RS2Object largeDoor = objects.closest(new Filter<RS2Object>() { @Override public boolean match(RS2Object rs2Object) { return rs2Object != null && rs2Object.getName().equals("Large door") && rs2Object.getPosition().equals(new Position(3293,3166,0)); } }); if(largeDoor != null){ getCamera().toEntity(largeDoor); if(largeDoor.isVisible()) try { largeDoor.interact("Open"); log("Opening the door"); return true; }catch(Exception e){ log("Door is already open"); return false; } } } The bot isn't Facing the camera on the door and doesn't interact with it. Thanks for helping me Edited July 28, 2015 by frozen8 Quote Link to comment Share on other sites More sharing options...
Bobrocket Posted July 28, 2015 Share Posted July 28, 2015 Thanks it's working! Also I'm having one last issue with the door. My current code to handle the door is this: if(!myPlayer().isMoving()) { RS2Object largeDoor = objects.closest(new Filter<RS2Object>() { @Override public boolean match(RS2Object rs2Object) { return rs2Object != null && rs2Object.getName().equals("Large door") && rs2Object.getPosition().equals(new Position(3293,3166,0)); } }); if(largeDoor != null){ getCamera().toEntity(largeDoor); if(largeDoor.isVisible()) try { largeDoor.interact("Open"); log("Opening the door"); return true; }catch(Exception e){ log("Door is already open"); return false; } } } The bot isn't Facing the camera on the door and doesn't interact with it. Thanks for helping me I don't think Camera#toEntity accepts an RS2Object as a parameter (could be wrong). Instead, use Entity for objects and NPC for NPCs: Entity door = getObjects().closest(new Filter<Entity>() { //match code }); if (!door.isVisible()) { getCamera().toEntity(door); } if (!door.hasAction("Open")) { log("Door is open"); return false; } door.interact("Open"); Position p = door.getPosition(); //Conditional sleep -> check objects at position p, see if they have action "Close" log("Door should be open"); return true; Quote Link to comment Share on other sites More sharing options...
Joseph Posted July 28, 2015 Share Posted July 28, 2015 I don't think Camera#toEntity accepts an RS2Object as a parameter (could be wrong). Instead, use Entity for objects and NPC for NPCs: Entity door = getObjects().closest(new Filter<Entity>() { //match code }); if (!door.isVisible()) { getCamera().toEntity(door); } if (!door.hasAction("Open")) { log("Door is open"); return false; } door.interact("Open"); Position p = door.getPosition(); //Conditional sleep -> check objects at position p, see if they have action "Close" log("Door should be open"); return true; Rs2 object extends entity so it's fine lol. @op leave it as rs2 object. Also the code seems fine. Try to see if the rs2 object is null. If it is it will explain why it doesn't interact Quote Link to comment Share on other sites More sharing options...
frozen8 Posted July 28, 2015 Author Share Posted July 28, 2015 I did some modifications now and it seems to be working fine. Also now another minor problem When I use that path: private final Position[] pathToHassan = { new Position(3275, 3169, 0), new Position(3279, 3177, 0), new Position(2388, 3180, 0), new Position(3291, 3172, 0), new Position(3292, 3167, 0) }; Sometime the bot click a couple time at the same position for some weird reason. I use this to go to a certain location: localWalker.walkPath(pathToHassan); Thanks a lot guys for helping me out so much! Quote Link to comment Share on other sites More sharing options...