This is a read only copy without any forum functionality of the old Modcraft forum.
If there is anything that you would like to have removed, message me on Discord via Kaev#5208.
Big thanks to Alastor for making this copy!

Menu

Author Topic: [LUA]  Select nearest NPC  (Read 1321 times)

Steff

  • Administrator
  • Creator of Worlds
  • *****
  • Posts: 4551
    • View Profile
[LUA]  Select nearest NPC
« 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)
« Last Edit: January 01, 1970, 01:00:00 am by Admin »
Please mark as solved if solved.
Don't ask if you could ask a question... JUST ask the Question.
You can send me also offline messages. I will answer if I get online.
Skype: project.modcraft
Discord: steff#6954

Laniax

  • Registred Member
  • Polygonshifter
  • *****
  • Posts: 62
    • View Profile
Re: [LUA]  Select nearest NPC
« Reply #1 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.
« Last Edit: January 01, 1970, 01:00:00 am by Admin »
Current project: AIO Emulation solution.