Thread Tools Display Modes
06-17-19, 11:19 PM   #1
johnka
A Defias Bandit
Join Date: Jun 2019
Posts: 2
Help wanted from a beginner (interacting with npc and run a command?)

Hello guys, first of all I really don't know much about coding in general and trying to learn the very basics right now, but i had a question about whatever this very small project i have in mind would work or not.

So what i want to do is create a script that runs the command </cancelform> when i right click a friendly NPC, this would be useful for druids in the upcoming wow classic as you can't talk to NPCs in animalforms.

So i would need some api/code that does something when i rightclick an NPC, and well therefor i want to ask if it is at all possible!

Just posting my very limited "psuedo" code, probbably more confusing then helpful but here it is:

if (UnitPlayerControlled("target")) then
{
//DO NOTHING
}

else if (IS UNIT TARGET NPC UNFRIENDLY?)
{
//DO NOTHING
}

else
{
/cancelform
}
end
  Reply With Quote
06-18-19, 12:24 AM   #2
elcius
A Cliff Giant
AddOn Author - Click to view addons
Join Date: Sep 2011
Posts: 75
It's probably not a simple task to do it in a single click, as both the cancelaura and the interact commands both require hardware events, and since interacting with npc's is an action that must be directly bound to an input, it gets even harder.

It's most likely possible to do it by using the mouse-down event for the cancelaura and the mouse-up event for the interact, but that's not an easy system to implement.
  Reply With Quote
06-18-19, 09:35 AM   #3
johnka
A Defias Bandit
Join Date: Jun 2019
Posts: 2
Hey dude, that makes sense, this made me come down to earth a bit, coding might not be as straight forward as i thought, even blizzards API seems a bit complicated overall, i think ill nip this idea of mine in the bud for now.

Thank you for your reply.
  Reply With Quote
06-18-19, 02:56 PM   #4
SDPhantom
A Pyroguard Emberseer
 
SDPhantom's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2006
Posts: 2,322
/cancelform is a secure command, meaning it runs a protected function. These are blocked from being run directly by addons. Long story short, the only way around this doesn't do what you're wanting, so this idea is impossible.
__________________
WoWInterface AddOns
"All I want is a pretty girl, a decent meal, and the right to shoot lightning at fools."
-Anders (Dragon Age: Origins - Awakening)
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » Help wanted from a beginner (interacting with npc and run a command?)

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off