WoWInterface

WoWInterface (https://www.wowinterface.com/forums/index.php)
-   Lua/XML Help (https://www.wowinterface.com/forums/forumdisplay.php?f=16)
-   -   Help wanted from a beginner (interacting with npc and run a command?) (https://www.wowinterface.com/forums/showthread.php?t=57210)

johnka 06-17-19 11:19 PM

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

elcius 06-18-19 12:24 AM

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.

johnka 06-18-19 09:35 AM

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.

SDPhantom 06-18-19 02:56 PM

/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.


All times are GMT -6. The time now is 05:27 PM.

vBulletin © 2024, Jelsoft Enterprises Ltd
© 2004 - 2022 MMOUI