FriedNuts 2 Share Posted December 7, 2021 I've been trying to figure this out but can't seem to figure it out. I've seen multiple examples but they are using a deprecated class/method to obtain the NPC as shown below. Anyone point me to the right direction on how to interact with an NPC. NPC cook = getNPCs().closest("Cook"); cook.interact("Talk"); Link to comment Share on other sites More sharing options...
Axolotl 31 Share Posted December 7, 2021 17 minutes ago, FriedNuts said: I've been trying to figure this out but can't seem to figure it out. I've seen multiple examples but they are using a deprecated class/method to obtain the NPC as shown below. Anyone point me to the right direction on how to interact with an NPC. NPC cook = getNPCs().closest("Cook"); cook.interact("Talk"); Hey, very close! NPC cook = NPCs.closest("Cook"); if(cook != null) { if(cook.interact("Talk")) log("Talking to cook"); } 2 things: 1 - Always check if it has been found before attempting to interact or it will through null point exceptions if it can't be found 2 - IMO its best to put the interact within an if statement as that way you KNOW you're interacting. Miss clicks can happen Link to comment Share on other sites More sharing options...
FriedNuts 2 Author Share Posted December 7, 2021 1 minute ago, Axolotl said: Hey, very close! NPC cook = NPCs.closest("Cook"); if(cook != null) { if(cook.interact("Talk")) log("Talking to cook"); } 2 things: 1 - Always check if it has been found before attempting to interact or it will through null point exceptions if it can't be found 2 - IMO its best to put the interact within an if statement as that way you KNOW you're interacting. Miss clicks can happen wow thank you. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.