Forum > Miscellaneous

[LUA]  Select nearest NPC

(1/1)

Steff:
Is there a way to select the nearest NPC with LUA. Client and Server commands are ok. (Trinity)

Laniax:
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: ---/targetenemy
--- End code ---
(this is the same as pushing TAB on ur keyboard)

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


--- Code: ---/targetfriend
--- End code ---
(same as CTRL+TAB)


if you however want to target players instead of npcs, u'd have to use.

--- Code: ---/targetenemyplayer
/targetfriendplayer

--- End code ---

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.

Navigation

[0] Message Index

Go to full version