Verify 0 Share Posted May 12, 2020 Hi, I am trying to build a standard method that interacts how I want with an object I selected. public static void doThis (MethodContext Act, String Action, String Object) { if(!Act.getLocalPlayer().isAnimating()) { if(Act.getGameObjects().closest(ObjectFilter -> ObjectFilter != null && ObjectFilter.hasAction(Action) && ObjectFilter.getName().equals(Object)).interact(Action)) { sleep(1200); } } } The logic is that if there is a close-by object that is not null, has the option to perform the Action I want and has the same name as the Object I named, then it would interact with the Object with the specified Action. It works fine when there is such an object, but it stops the whole script when it can't find the object. I would like to know how it would be possible to just do nothing if no object is detected and to let the script continue to loop. I thought that is what I did by putting the whole Act.getGameObjects.closest ... in an IF statement, but that doesn't work. Link to comment Share on other sites More sharing options...
Pandemic 2703 Share Posted May 12, 2020 You need to check if the object exists first: public static void doThis (MethodContext Act, String Action, String Object) { if(!Act.getLocalPlayer().isAnimating()) { GameObject gameObject = Act.getGameObjects().closest(ObjectFilter -> ObjectFilter != null && ObjectFilter.hasAction(Action) && ObjectFilter.getName().equals(Object)); if(gameObject != null && gameObject.interact(Action)) { sleep(1200); } } } Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.