Modcraft - The community dedicated to quality WoW modding!

Wrath of the Lich King Modding => Miscellaneous => Topic started by: Steff on January 13, 2012, 12:17:11 pm

Title: [LUA]  Select nearest NPC
Post by: Steff on January 13, 2012, 12:17:11 pm
Is there a way to select the nearest NPC with LUA. Client and Server commands are ok. (Trinity)
Title: Re: [LUA]  Select nearest NPC
Post by: Laniax on January 13, 2012, 06:47:50 pm
As far as i know, In the WoW-API the target nearest functions are protected (meaning they cannot be called from Addon codes). What you can do however, is let ur addon create a macro and let that run whenever you want.

To target the nearest enemy (npc) in a macro:
Code: [Select]
/targetenemy (this is the same as pushing TAB on ur keyboard)

if you want to target an friendly npc, u can use

Code: [Select]
/targetfriend (same as CTRL+TAB)


if you however want to target players instead of npcs, u'd have to use.
Code: [Select]
/targetenemyplayer
/targetfriendplayer

They work in the same fashion, just for players instead of npcs.

Do note; each of these commands may only be called ONCE per macro. If you want to check for both NPCs and Players, you'd have to call 2 seperate macros to do so.