December 28, 201510 yr Probably super simple I'm just not sure. Been a while since I've been on here. Also my script keeps getting stuck saying there are arrows to be picked up but there aren't. Any ideas why? public boolean arrowsPresent() { if (getGroundItems().closest(arrowType) != null) { return true; } return false; } Edited December 28, 201510 yr by Paradox68
December 28, 201510 yr Probably super simple I'm just not sure. Been a while since I've been on here. I would use a filter like this: Filter<NPC> monsterFilter = new Filter<NPC>() { @Override public boolean match(NPC n) { if (n.getId() != monsterID) return false; if(!n.getName().equals(monsterName)) return false; if(n.isUnderAttack()) return false; return true; } }; then you can just say: NPC monster = getNpcs().closest(monsterFilter); Did that help? Edited December 28, 201510 yr by AresScripts
December 28, 201510 yr Author I would use a filter like this: Filter<NPC> monsterFilter = new Filter<NPC>() { @Override public boolean match(NPC n) { if (n.getId() != monsterID) return false; if(!n.getName().equals(monsterName)) return false; if(n.isUnderAttack()) return false; return true; } }; then you can just say: NPC monster = getNpcs().closest(monsterFilter); Did that help? A lot actually, thanks dude. Not to be mr. stupid but what's this about? Edited December 28, 201510 yr by Paradox68
December 28, 201510 yr A lot actually, thanks dude. Not to be mr. stupid but what's this about? I haven't used eclipse in a while but i remember that being not necessary to fix. Warnings usually aren't an actual problem(someone correct me if im wrong) Edited December 28, 201510 yr by AresScripts
December 28, 201510 yr I would use a filter like this: Filter<NPC> monsterFilter = new Filter<NPC>() { @Override public boolean match(NPC n) { if (n.getId() != monsterID) return false; if(!n.getName().equals(monsterName)) return false; if(n.isUnderAttack()) return false; return true; } }; then you can just say: NPC monster = getNpcs().closest(monsterFilter); Did that help? Or you could just do: NPC monster = getNpcs().closest(npc -> npc.getName().equals("Cow") && !npc.isUnderAttack()); A lot actually, thanks dude. Not to be mr. stupid but what's this about? Just suppress it, the warning is for an operation that is potentially unsafe, but in this case we know it is fine. @SuppressWarnings("unchecked") NPC monster = getNpcs().closest(npc -> npc.getName().equals("Cow") && !npc.isUnderAttack()); Also with regards to your arrow method, it can be simplified to: public boolean arrowsPresent() { return getGroundItems().closest(arrowType) != null; } And it should work fine, it is probably an issue somewhere else in your code. Edited December 28, 201510 yr by Explv
December 28, 201510 yr Or you could just do: NPC monster = getNpcs().closest(npc -> npc.getName().equals("Cow") && !npc.isUnderAttack()); Just suppress it, the warning is for an operation that is potentially unsafe, but in this case we know it is fine. @SuppressWarnings("unchecked") NPC monster = getNpcs().closest(npc -> npc.getName().equals("Cow") && !npc.isUnderAttack()); Also with regards to your arrow method, it can be simplified to: public boolean arrowsPresent() { return getGroundItems().closest(arrowType) != null; } And it should work fine, it is probably an issue somewhere else in your code. Ah. I need to study up on lambda expressions
December 29, 201510 yr Ah. I need to study up on lambda expressions I found your Filter to be written a little oddly as well Why would you do: Filter<NPC> monsterFilter = new Filter<NPC>() { @Override public boolean match(NPC n) { if (n.getId() != monsterID) return false; if(!n.getName().equals(monsterName)) return false; if(n.isUnderAttack()) return false; return true; } }; when you could just do: Filter<NPC> monsterFilter = new Filter<NPC>() { @Override public boolean match(NPC n) { return n.getName().equals("Cow") && !n.isUnderAttack(); } }; But yeah, lambdas make everything more simple anyway ^_^ Edited December 29, 201510 yr by Explv
December 29, 201510 yr I found your Filter to be written a little oddly as well Why would you do: Filter<NPC> monsterFilter = new Filter<NPC>() { @Override public boolean match(NPC n) { if (n.getId() != monsterID) return false; if(!n.getName().equals(monsterName)) return false; if(n.isUnderAttack()) return false; return true; } }; when you could just do: Filter<NPC> monsterFilter = new Filter<NPC>() { @Override public boolean match(NPC n) { return n.getName().equals("Cow") && !n.isUnderAttack(); } }; But yeah, lambdas make everything more simple anyway Even though that takes up less lines of code, I like to only do one "filter" per if statement because its easier to debug for me.
Create an account or sign in to comment