Beck Posted November 28, 2020 Share Posted November 28, 2020 (edited) I'm working on a script which lights the logs on top of Lumbridge Castle. Quite often the logs respawn before the previous fire may despawn. How would I go about "ignoring" (of sorts) the log if it is on the same tile as the fire? I'm assuming it could be done at the start of the onLoop, where instead of assigning the entity outside of the onLoop, I reassign it at the start of each iteration. Unsure though. Entity log = getGroundItems().closest("Logs"); New to the OSBot API so sorry if this is an ignorant question All feedback would be appreciated. Edited November 28, 2020 by R1pple Quote Link to comment Share on other sites More sharing options...
BravoTaco Posted November 29, 2020 Share Posted November 29, 2020 (edited) 6 hours ago, R1pple said: I'm working on a script which lights the logs on top of Lumbridge Castle. Quite often the logs respawn before the previous fire may despawn. How would I go about "ignoring" (of sorts) the log if it is on the same tile as the fire? I'm assuming it could be done at the start of the onLoop, where instead of assigning the entity outside of the onLoop, I reassign it at the start of each iteration. Unsure though. Entity log = getGroundItems().closest("Logs"); New to the OSBot API so sorry if this is an ignorant question All feedback would be appreciated. To do this you can declare a Filter and than use that Filter to get the closest log. To declare a Filter to be used you would set it as a variable wherever you need it like so. Heres a link to the Filter api doc. private final Filter<RS2Object> logFilter = new Filter<RS2Object>() { @Override public boolean match(RS2Object rs2Object) { return rs2Object.getName().equalsIgnoreCase("logName") && getMap().canReach(rs2Object) && getObjects().get(rs2Object.getPosition().getX(), rs2Object.getPosition().getY()) .stream().noneMatch((object) -> object.getName().equalsIgnoreCase("Fire")); } }; You would need to replace the logName string with the name of the log you are looking for. This Filter will check a few conditions first, if the RS2Object's name matches the supplied string, second it checks to see if you can reach the object lastly, it checks to see if there are no fires at that position. To use the filter in the onLoop() method you would call getObjects().closest(logFilter) and set that equal to a variable than null check it before acting up on it. Like so. RS2Object log = getObjects().closest(logFilter); if (log != null) { doLogic(); } Edited November 29, 2020 by BravoTaco 2 Quote Link to comment Share on other sites More sharing options...
Beck Posted November 29, 2020 Author Share Posted November 29, 2020 4 hours ago, BravoTaco said: To do this you can declare a Filter and than use that Filter to get the closest log. To declare a Filter to be used you would set it as a variable wherever you need it like so. Heres a link to the Filter api doc. private final Filter<RS2Object> logFilter = new Filter<RS2Object>() { @Override public boolean match(RS2Object rs2Object) { return rs2Object.getName().equalsIgnoreCase("logName") && getMap().canReach(rs2Object) && getObjects().get(rs2Object.getPosition().getX(), rs2Object.getPosition().getY()) .stream().noneMatch((object) -> object.getName().equalsIgnoreCase("Fire")); } }; You would need to replace the logName string with the name of the log you are looking for. This Filter will check a few conditions first, if the RS2Object's name matches the supplied string, second it checks to see if you can reach the object lastly, it checks to see if there are no fires at that position. To use the filter in the onLoop() method you would call getObjects().closest(logFilter) and set that equal to a variable than null check it before acting up on it. Like so. RS2Object log = getObjects().closest(logFilter); if (log != null) { doLogic(); } Awesome, thanks for the help. Quote Link to comment Share on other sites More sharing options...