Thread Tools Display Modes
05-21-21, 02:13 PM   #1
phage
A Deviate Faerie Dragon
Join Date: Apr 2021
Posts: 15
Can someone write me a simple add-on?

This is something I actually already have in another add-on but I'd like to make it a standalone add-on. I can't figure it out how to steal it from the code so I'm hoping someone here can write it for me. This function needs to target an npc and then interact with them and I'd like to be able to bind the function to any key. Also, whenever the add-on is turned on, I want to be able to override whatever key I designate it to inside the code.

and yes, it is possible, see below.

https://streamable.com/pd8rpp
  Reply With Quote
05-21-21, 02:33 PM   #2
sezz
A Chromatic Dragonspawn
AddOn Author - Click to view addons
Join Date: Apr 2008
Posts: 158
1. use a macro that contains /target npcname
2. bind "interact with target"

?
  Reply With Quote
05-21-21, 03:05 PM   #3
phage
A Deviate Faerie Dragon
Join Date: Apr 2021
Posts: 15
Originally Posted by sezz View Post
1. use a macro that contains /target npcname
2. bind "interact with target"

?
I want to have them bound to the same key and you can't do that with basic macros.
  Reply With Quote
05-21-21, 04:42 PM   #4
Kanegasi
A Molten Giant
 
Kanegasi's Avatar
AddOn Author - Click to view addons
Join Date: Apr 2007
Posts: 666
Originally Posted by phage View Post
This is something I actually already have in another add-on
It would be a hell of a lot easier if you actually shared that addon. It wouldn't make sense for anyone to "make" this addon when the code already exists and someone can just take it out.
  Reply With Quote
05-21-21, 05:00 PM   #5
phage
A Deviate Faerie Dragon
Join Date: Apr 2021
Posts: 15
Originally Posted by Kanegasi View Post
It would be a hell of a lot easier if you actually shared that addon. It wouldn't make sense for anyone to "make" this addon when the code already exists and someone can just take it out.
It's tied into too many functions for someone to easily remove. I didn't realize this was such an in-depth coding request.
  Reply With Quote
05-21-21, 05:20 PM   #6
Kanegasi
A Molten Giant
 
Kanegasi's Avatar
AddOn Author - Click to view addons
Join Date: Apr 2007
Posts: 666
Let others make that determination. Honestly, the fact that you can't write what you believe is "simple" is closely related to the fact that you can't extract this functionality from existing code.
  Reply With Quote
05-21-21, 08:18 PM   #7
sezz
A Chromatic Dragonspawn
AddOn Author - Click to view addons
Join Date: Apr 2008
Posts: 158
Originally Posted by phage View Post
I want to have them bound to the same key and you can't do that with basic macros.
Your current addon works with 1 single button press without using a lua unlocker on official servers?

Just curious, because InteractTarget and RunBinding are protected and I currently can't think of any other method to interact with a NPC, but maybe I'm missing something.
  Reply With Quote
05-22-21, 12:59 AM   #8
phage
A Deviate Faerie Dragon
Join Date: Apr 2021
Posts: 15
Originally Posted by sezz View Post
Your current addon works with 1 single button press without using a lua unlocker on official servers?

Just curious, because InteractTarget and RunBinding are protected and I currently can't think of any other method to interact with a NPC, but maybe I'm missing something.
What's a lua unlocker?
  Reply With Quote
05-22-21, 11:58 AM   #9
Seerah
Fishing Trainer
 
Seerah's Avatar
WoWInterface Super Mod
Featured
Join Date: Oct 2006
Posts: 10,860
Your gif doesn't prove what you think it proves.

And you still haven't linked the addon you are currently using for this purpose.
__________________
"You'd be surprised how many people violate this simple principle every day of their lives and try to fit square pegs into round holes, ignoring the clear reality that Things Are As They Are." -Benjamin Hoff, The Tao of Pooh

  Reply With Quote
05-22-21, 12:13 PM   #10
phage
A Deviate Faerie Dragon
Join Date: Apr 2021
Posts: 15
Originally Posted by Seerah View Post
Your gif doesn't prove what you think it proves.

And you still haven't linked the addon you are currently using for this purpose.
I'm still not going to link my add-on as it's a private add-on and I don't want others to have access to it.
My gif shows I'm pressing a single keybind to perform each action, what do you mean?
  Reply With Quote
05-22-21, 12:49 PM   #11
SDPhantom
A Pyroguard Emberseer
 
SDPhantom's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2006
Posts: 2,313
There's an "Interact With Mouseover" keybind under "Targeting".

Edit: It's available to all clients, retail, classic, and BCC.
Attached Thumbnails
Click image for larger version

Name:	Interact-With-Mouseover.png
Views:	220
Size:	515.3 KB
ID:	9636  
__________________
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)

Last edited by SDPhantom : 05-22-21 at 12:57 PM.
  Reply With Quote
05-22-21, 06:26 PM   #12
jeffy162
A Pyroguard Emberseer
 
jeffy162's Avatar
AddOn Author - Click to view addons
Join Date: May 2009
Posts: 2,364
Originally Posted by phage View Post
I'm still not going to link my add-on as it's a private add-on and I don't want others to have access to it.
My gif shows I'm pressing a single keybind to perform each action, what do you mean?
If the addon is NOT listed on a public addon site, how can anyone get access to it? If it IS listed on a public addon site, how can it be considered a "private addon"? As far as your GIF goes, it didn't tell me anything. Sorry.
__________________
Ahhhh, the vagueries of the aging mind. Wait.... What was I saying?


Carbonite <----- GitHub main module (Maps ONLY) download link. The other modules are also available on GitHub.
Carbonite-CLASSIC<----- GitHub link to Carbonite Classic. Thanks to ircdirk for this!
  Reply With Quote
05-22-21, 07:38 PM   #13
phage
A Deviate Faerie Dragon
Join Date: Apr 2021
Posts: 15
Originally Posted by jeffy162 View Post
If the addon is NOT listed on a public addon site, how can anyone get access to it? If it IS listed on a public addon site, how can it be considered a "private addon"? As far as your GIF goes, it didn't tell me anything. Sorry.
If I shared it here, it wouldn't be private.

Anyways, here's the section of the code that handles the one-button target and interact with function. I'm not really sure why you're all saying this is impossible.

I removed a few lines as they're irrelevant to the process.

Code:
local addonName = ...
ezopen_keybind = 'SPACE'
 
function EzOpenMixin:OnEvent(e, ...)
        CreateFrame("Button", "setButton", UIParent, "SecureActionButtonTemplate")
        setButton:SetAttribute("type", "macro")
        setButton:SetAttribute("macrotext", "/run SetOverrideBinding(\""..ezopen_keybind.."\", 'INTERACTTARGET')\n/target NPC NAME HERE")
        setButton:RegisterForClicks("AnyUp", "AnyDown")
        SetOverrideBindingClick(self, false, ezopen_keybind, 'setButton')
    elseif e == "AUCTION_HOUSE_SHOW" then
        SetOverrideBindingClick(self, false, ezopen_keybind, 'setButton')
    elseif e == "AUCTION_HOUSE_CLOSED" then
        -- ClearOverrideBindings(self)
    elseif e == "AUCTION_HOUSE_THROTTLED_MESSAGE_RESPONSE_RECEIVED" then
        C_Timer.After(0.1, function() self.isReady = true end)
    elseif e == "AUCTION_HOUSE_THROTTLED_MESSAGE_SENT" then
        self.isReady = false
    end
end
  Reply With Quote
05-24-21, 03:20 PM   #14
sezz
A Chromatic Dragonspawn
AddOn Author - Click to view addons
Join Date: Apr 2008
Posts: 158
Originally Posted by phage View Post
Anyways, here's the section of the code that handles the one-button target and interact with function. I'm not really sure why you're all saying this is impossible.
Well, because it's 2 button presses - I specifically asked if it's only 1 single key press.
Nevertheless, I'm glad you found it though Do you still need help with removing everything that's unrelated to targetting and interacting?
  Reply With Quote
05-24-21, 06:27 PM   #15
phage
A Deviate Faerie Dragon
Join Date: Apr 2021
Posts: 15
Originally Posted by sezz View Post
Well, because it's 2 button presses - I specifically asked if it's only 1 single key press.
Nevertheless, I'm glad you found it though Do you still need help with removing everything that's unrelated to targetting and interacting?
Yes, I could use the help. I have a hard time understanding lua and explaining what I mean. What I meant was creating an add-on that would be able to do all the functions within one key but have multiple key presses that perform different functions. I wasn't sure how to word that initially.
  Reply With Quote
05-25-21, 12:05 PM   #16
Seerah
Fishing Trainer
 
Seerah's Avatar
WoWInterface Super Mod
Featured
Join Date: Oct 2006
Posts: 10,860
Ah, yes. That is indeed 2 button presses, not one. So long as they are not protected functions, you can do

Code:
if condition1 then
   do first thing
elseif condition2 then
   do other thing
else
   do third thing
end
(Though the code you linked is for an event handler, not button presses.)
(Oh, and we can't actually see button presses in a gif. )
__________________
"You'd be surprised how many people violate this simple principle every day of their lives and try to fit square pegs into round holes, ignoring the clear reality that Things Are As They Are." -Benjamin Hoff, The Tao of Pooh


Last edited by Seerah : 05-25-21 at 12:08 PM.
  Reply With Quote
05-25-21, 03:04 PM   #17
sezz
A Chromatic Dragonspawn
AddOn Author - Click to view addons
Join Date: Apr 2008
Posts: 158
Originally Posted by phage View Post
Yes, I could use the help. I have a hard time understanding lua and explaining what I mean. What I meant was creating an add-on that would be able to do all the functions within one key but have multiple key presses that perform different functions. I wasn't sure how to word that initially.
I'd do it like this:

Lua Code:
  1. local binding = "SPACE";
  2. local target = "Collector Unta";
  3.  
  4. local UnitExists, UnitName, SetOverrideBinding, ClearOverrideBindings, SetOverrideBindingClick, IsMounted, InCombatLockdown = UnitExists, UnitName, SetOverrideBinding, ClearOverrideBindings, SetOverrideBindingClick, IsMounted, InCombatLockdown;
  5.  
  6. local button = CreateFrame("Button", "PhagesCuddleUntaButton", UIParent, "SecureActionButtonTemplate");
  7. button:RegisterForClicks("AnyUp", "AnyDown");
  8. button:SetAttribute("type", "macro")
  9. button:SetAttribute("macrotext", "/cast [nomounted] Mighty Caravan Brutosaur\n/targetexact "..target);
  10. button:SetScript("PostClick", function(self)
  11.     if (not InCombatLockdown() and UnitExists("target") and UnitName("target") == target) then
  12.         SetOverrideBinding(self, true, binding, "INTERACTTARGET");
  13.     end
  14. end);
  15.  
  16. button.Reset = function(self)
  17.     ClearOverrideBindings(self);
  18.     SetOverrideBindingClick(self, false, binding, self:GetName());
  19. end
  20.  
  21. button:RegisterEvent("PLAYER_ENTERING_WORLD");
  22. button:RegisterEvent("PLAYER_TARGET_CHANGED");
  23. button:RegisterEvent("PLAYER_MOUNT_DISPLAY_CHANGED");
  24.  
  25. button:SetScript("OnEvent", function(self, event)
  26.     if (not InCombatLockdown() and (event == "PLAYER_ENTERING_WORLD" or (event == "PLAYER_TARGET_CHANGED" and (not UnitExists("target") or UnitName("target") ~= target)) or event == "PLAYER_MOUNT_DISPLAY_CHANGED" and not IsMounted())) then
  27.         self:Reset();
  28.     end
  29. end);

Simple logic: If Unta is the target it interacts with her, otherwise it mounts up (if not mounted) and also tries to target Unta.

Seems to work fine on the PTR (can't test on live because my subscription just expired and token prices are ridiculous ), only issue is that it will try to mount up again if you press the key again exactly before the mount cast finished (propably dependant on spell-queuing settings, you'll have to try it yourself if it's annoying).
  Reply With Quote
05-25-21, 11:45 PM   #18
phage
A Deviate Faerie Dragon
Join Date: Apr 2021
Posts: 15
Originally Posted by sezz View Post
I'd do it like this:

Lua Code:
  1. local binding = "SPACE";
  2. local target = "Collector Unta";
  3.  
  4. local UnitExists, UnitName, SetOverrideBinding, ClearOverrideBindings, SetOverrideBindingClick, IsMounted, InCombatLockdown = UnitExists, UnitName, SetOverrideBinding, ClearOverrideBindings, SetOverrideBindingClick, IsMounted, InCombatLockdown;
  5.  
  6. local button = CreateFrame("Button", "PhagesCuddleUntaButton", UIParent, "SecureActionButtonTemplate");
  7. button:RegisterForClicks("AnyUp", "AnyDown");
  8. button:SetAttribute("type", "macro")
  9. button:SetAttribute("macrotext", "/cast [nomounted] Mighty Caravan Brutosaur\n/targetexact "..target);
  10. button:SetScript("PostClick", function(self)
  11.     if (not InCombatLockdown() and UnitExists("target") and UnitName("target") == target) then
  12.         SetOverrideBinding(self, true, binding, "INTERACTTARGET");
  13.     end
  14. end);
  15.  
  16. button.Reset = function(self)
  17.     ClearOverrideBindings(self);
  18.     SetOverrideBindingClick(self, false, binding, self:GetName());
  19. end
  20.  
  21. button:RegisterEvent("PLAYER_ENTERING_WORLD");
  22. button:RegisterEvent("PLAYER_TARGET_CHANGED");
  23. button:RegisterEvent("PLAYER_MOUNT_DISPLAY_CHANGED");
  24.  
  25. button:SetScript("OnEvent", function(self, event)
  26.     if (not InCombatLockdown() and (event == "PLAYER_ENTERING_WORLD" or (event == "PLAYER_TARGET_CHANGED" and (not UnitExists("target") or UnitName("target") ~= target)) or event == "PLAYER_MOUNT_DISPLAY_CHANGED" and not IsMounted())) then
  27.         self:Reset();
  28.     end
  29. end);

Simple logic: If Unta is the target it interacts with her, otherwise it mounts up (if not mounted) and also tries to target Unta.

Seems to work fine on the PTR (can't test on live because my subscription just expired and token prices are ridiculous ), only issue is that it will try to mount up again if you press the key again exactly before the mount cast finished (propably dependant on spell-queuing settings, you'll have to try it yourself if it's annoying).

Very cool! I tried to install it by saving it as a .lua file, creating a toc with the proper callings, but I couldn't turn it on from my add-ons list. Is there something else I need to do for it to appear on that list?
  Reply With Quote
05-26-21, 02:23 AM   #19
Xrystal
nUI Maintainer
 
Xrystal's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Feb 2006
Posts: 5,892
Did you make sure you log out of the game before adding the files to the respective folder ?
Does the toc file have all the required entries ?
__________________
  Reply With Quote
05-26-21, 05:57 AM   #20
phage
A Deviate Faerie Dragon
Join Date: Apr 2021
Posts: 15
Originally Posted by Xrystal View Post
Did you make sure you log out of the game before adding the files to the respective folder ?
Does the toc file have all the required entries ?
I did but I'm not sure what all the toc needs. It's also very likely that I didn't save the toc file as a .toc.

Yep, that was it, oops.
  Reply With Quote

WoWInterface » AddOns, Compilations, Macros » AddOn Search/Requests » Can someone write me a simple add-on?

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