crazykid080 14 Share Posted October 1, 2020 I've been trying to grab a reference to Zaff in Varrock but for some reason it keeps returning null even when I'm in his shop. I've tried filtering by name and ID, but neither works, am I missing something? For reference this is my filter code Entity zaff = GameObjects.closest(check -> check.getName().contains("Zaff")); Link to comment Share on other sites More sharing options...
Neffarion 485 Share Posted October 1, 2020 You should try null checking the "check" before doing the name verification Link to comment Share on other sites More sharing options...
crazykid080 14 Author Share Posted October 1, 2020 I'm not 100% sure what you mean by null checking the check, I assume it's not as simple as just adding check != null correct? Link to comment Share on other sites More sharing options...
AsBakedAsCake 202 Share Posted October 1, 2020 6 minutes ago, crazykid080 said: I've been trying to grab a reference to Zaff in Varrock but for some reason it keeps returning null even when I'm in his shop. I've tried filtering by name and ID, but neither works, am I missing something? For reference this is my filter code Entity zaff = GameObjects.closest(check -> check.getName().contains("Zaff")); Also, why are you using GameObject? Zaff is an NPC/Shop, not an object. NPC Zaff = NPCs.closest("Zaff")); if(Zaff ! = null){ interact(); } This is pretty basic stuff, I'd recommend checking out some scripting tutorials Link to comment Share on other sites More sharing options...
Hmm 31 Share Posted October 1, 2020 11 minutes ago, crazykid080 said: I'm not 100% sure what you mean by null checking the check, I assume it's not as simple as just adding check != null correct? Yes, he meant that. NPC zaff = NPCs.closest(check -> check != null && check.getName().contains("Zaff")); Then you can interact by doing: zaff.interact("Trade"); - if you wanted to trade him. Link to comment Share on other sites More sharing options...
crazykid080 14 Author Share Posted October 1, 2020 9 minutes ago, AsBakedAsCake said: Also, why are you using GameObject? Zaff is an NPC/Shop, not an object. I knew I was missing something! I've looked at some of the tutorials but I didn't see anything about NPCs, probably just missed it Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.