PlagueDoctor Posted October 31, 2016 Share Posted October 31, 2016 (edited) He was using the shorthand lambda expression, for the Filter<NPC> before. I don't know why he changed it to what he has now. getNpcs().closest(new Filter<NPC>() { @[member='Override'] public boolean match(NPC obj) { return obj.getHealthPercent() > 1; } }) ; is the same as getNpcs().closest(npc -> npc.getHealthPercent() > 1); @@PuppyLover101, change it back to what you had before, where you had the yellow lines. The yellow lines just means there is a warning. It will still compile and run. In eclipse, you can hover over the underlined lines of code and it will tell you what the warning is. It will also give you suggestions on how to fix it. If you can screenshot the warning tool tip, we can help you get rid of it. Sorry guys i helped him rewrite the script differently lul. I didn't know how to fix the issues with the way he wrote it so i showed him another way to write it and explained it to him. I told him i could be wrong though :<. It works though. Here's how his code is now http://pastebin.com/PEeiMSfh (does the job) I've told him to ask me about the parts of it he doesn't understand and i'll explain it. I did this before i read this thread btw. edit: i've never made a combat script before fyi Edited October 31, 2016 by PlagueDoctor Quote Link to comment Share on other sites More sharing options...
Manner Posted October 31, 2016 Share Posted October 31, 2016 Sorry guys i helped him rewrite the script differently lul. I didn't know how to fix the issues with the way he wrote it so i showed him another way to write it and explained it to him. I told him i could be wrong though :<. It works though. Here's how his code is now http://pastebin.com/PEeiMSfh (does the job) I've told him to ask me about the parts of it he doesn't understand and i'll explain it. I did this before i read this thread btw. edit: i've never made a combat script before fyi If the closest cow is under attack, the script will not do anything. Take a look at this: http://pastebin.com/cTGie1Dq Quote Link to comment Share on other sites More sharing options...
PlagueDoctor Posted October 31, 2016 Share Posted October 31, 2016 (edited) If the closest cow is under attack, the script will not do anything. Take a look at this: http://pastebin.com/cTGie1Dq if (cow != null) { if (cow.interact("Attack")){ new ConditionalSleep(5000) { @[member='Override'] public boolean condition() throws InterruptedException { return myPlayer().getInteracting() != null; } }.sleep(); } Ah i see, very nice. Sorry if i wasted anyones time by proxy. I quite enjoyed helping him cause i was learning stuff as i went aswell. Edit: http://pastebin.com/i9Tw935f - code is now like so. Thanks for the link Manner, looks like it will work well. NPCs closest returns a single NPC, not a collection of NPCs for you to filter. You want something like: Optional<NPC> suitableNpc = getNpcs().getAll().stream().filter(npc -> npc.getHealthPercent() > 1).findFirst(); if (suitableNpc.isPresent()) { suitableNpc.get().interact("examine"); } You may want to look a little bit into Java 8 streams before using them. Edit: Or better yet you can use the FilterAPI way which is native to OSBot getNpcs().closest(new Filter<NPC>() { @[member='Override'] public boolean match(NPC obj) { return obj.getHealthPercent() > 1; } }) ; EntityAPI: http://osbot.org/api/org/osbot/rs07/api/EntityAPI.html This is very useful, i'm going to read up on this as well. Thanks for posting. Edited October 31, 2016 by PlagueDoctor Quote Link to comment Share on other sites More sharing options...