Ales 2 Share Posted October 24, 2015 Is there a better(fastest way) to get object from game instead of using getGameObjects().closest()? Sometimes the client is searching for the object for few seconds and therefore making script slower. Ty in advance. Link to comment Share on other sites More sharing options...
RealEngine 24 Share Posted October 24, 2015 GameObject door = getGameObjects().closest(p -> p != null && p.getID() == doorEastclosedID); no but you want to have a filter when looking for game objects. Otherwise i think you are mistaking the script being slow for another part of your programming. That method happens really fast. Link to comment Share on other sites More sharing options...
Ales 2 Author Share Posted October 24, 2015 (edited) GameObject door = getGameObjects().closest(p -> p != null && p.getID() == doorEastclosedID); no but you want to have a filter when looking for game objects. Otherwise i think you are mistaking the script being slow for another part of your programming. That method happens really fast. Thanks a lot, how can i change it to yours with this code? not with id but String? GameObject fungi = getGameObjects().closest("Fungi on log"); Edited October 24, 2015 by Ales Link to comment Share on other sites More sharing options...
RealEngine 24 Share Posted October 24, 2015 (edited) Thanks a lot, how can i change it to yours with this code? not with id but String? GameObject fungi = getGameObjects().closest("Fungi on log"); GameObject log = getGameObjects().closest(p-> p !=null && p.getName().equals(funginame)); the closest method takes a filter. Now in java 8 you dont have to make a filter you can just use lambda expressions. Lambdas take the form of (parameter -> expression body) edit sorry you asked for names. i changed the code. Edited October 24, 2015 by RealEngine Link to comment Share on other sites More sharing options...
Ales 2 Author Share Posted October 24, 2015 GameObject log = getGameObjects().closest(p-> p !=null && p.getName().equals(funginame)); the closest method takes a filter. Now in java 8 you dont have to make a filter you can just use lambda expressions. Lambdas take the form of (parameter -> expression body) edit sorry you asked for names. i changed the code. alright thanks a lot so i assume i have to use .closest twice for one object.? I'll change code of my script later and let you know if speed improved Link to comment Share on other sites More sharing options...
Dreamlicker 749 Share Posted October 24, 2015 (edited) alright thanks a lot so i assume i have to use .closest twice for one object.? I'll change code of my script later and let you know if speed improvedYou only need to do it once. getGameObjects().closest(item -> item.getName().contains("fungi")); Edited October 24, 2015 by Dreamlicker Link to comment Share on other sites More sharing options...
Ales 2 Author Share Posted October 24, 2015 GameObject log = getGameObjects().closest(p-> p !=null && p.getName().equals(funginame)); the closest method takes a filter. Now in java 8 you dont have to make a filter you can just use lambda expressions. Lambdas take the form of (parameter -> expression body) edit sorry you asked for names. i changed the code. You only need to do it once. getGameObjects().closest(item -> item.getName().contains("fungi")); thanks a lot, just tested it is faster Link to comment Share on other sites More sharing options...
Nuclear Nezz 1996 Share Posted October 24, 2015 wot you asked for something faster than closest and then said closest was faster? :x Dogerina 1 Link to comment Share on other sites More sharing options...
Ales 2 Author Share Posted October 24, 2015 (edited) wot you asked for something faster than closest and then said closest was faster? :x i am sorry i just tested script again. Same thing is happening currently. Mouse wouldn't interact with an item fast enough. Usually it takes 2-3 seconds to pick up an item which makes less money/hour. This method hover mouse next to an item after 3 seconds it hovers on item and clicks it and repeats. I want something that would hover mouse over item and click almost instantaneously. Here is my method, any help would be appreciated. public void picking() { GameObject log = getGameObjects().closest(item -> item !=null && item.getName().contains("Fungi on log")); //GameObject log = getGameObjects().closest(p -> p != null && p.getName().equals(fungi)); log.interact("Pick"); // move Camera or missclick fungi.! } Edited October 24, 2015 by Ales Link to comment Share on other sites More sharing options...
Nuclear Nezz 1996 Share Posted October 24, 2015 i am sorry i just tested script again. Same thing is happening currently. Mouse wouldn't interact with an item fast enough. Usually it takes 2-3 seconds to pick up an item which makes less money/hour. This method hover mouse next to an item after 3 seconds it hovers on item and clicks it and repeats. I want something that would hover mouse over item and click almost instantaneously. Here is my method, any help would be appreciated. public void picking() { GameObject log = getGameObjects().closest(item -> item !=null && item.getName().contains("Fungi on log")); //GameObject log = getGameObjects().closest(p -> p != null && p.getName().equals(fungi)); log.interact("Pick"); // move Camera or missclick fungi.! } ...what are you running this script on for that to take a few seconds >_> Link to comment Share on other sites More sharing options...
Recommended Posts