Quantcast Access protected functions? TargetUnit? - WoWInterface
Thread Tools Display Modes
02-24-19, 05:46 PM   #1
wille480
A Wyrmkin Dreamwalker
Join Date: Jan 2017
Posts: 56
Access protected functions? TargetUnit?

How would i go about targeting a UnitId through a frame? Since the TargetUnit function from the wow api is protected. i have no work around through this. I tried to do a cheeky print("/target ".. UnitName("whatever")) but that did not work. Is there anything i have to do to unlock the protected function? or is there no way around this?
  Reply With Quote
02-24-19, 06:38 PM   #2
Kanegasi
A Rage Talon Dragon Guard
 
Kanegasi's Avatar
AddOn Author - Click to view addons
Join Date: Apr 2007
Posts: 317
You cannot target anything using an addon. You have to click, manually type /target, or use /target in a macro you click. There is no way around this. If you find a way, it'll be fixed pretty fast.
  Reply With Quote
02-24-19, 06:48 PM   #3
wille480
A Wyrmkin Dreamwalker
Join Date: Jan 2017
Posts: 56
Originally Posted by Kanegasi View Post
You cannot target anything using an addon. You have to click, manually type /target, or use /target in a macro you click. There is no way around this. If you find a way, it'll be fixed pretty fast.
Wow really? So i have to give up on my frame addon? :O
How do the people that writes elvUI or similar addons do it? with their frames?

Last edited by wille480 : 02-24-19 at 06:51 PM.
  Reply With Quote
02-24-19, 07:58 PM   #4
Fizzlemizz
I did that?
 
Fizzlemizz's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Dec 2011
Posts: 1,006
It would be best if you actually describe what you are trying to do or what effect it is you see in ElvUI that you are trying to duplicate. As far as I know ElvUI doesn't have Target("Phred") function.
__________________
Fizzlemizz
Maintainer of Discord Unit Frames and Discord Art.
Author of FauxMazzle, FauxMazzleHUD and Move Pad Plus.
  Reply With Quote
02-24-19, 08:11 PM   #5
elcius
A Wyrmkin Dreamwalker
AddOn Author - Click to view addons
Join Date: Sep 2011
Posts: 54
you need to create your frame as a secure action button, and then bind it with either the "target" or "macro" actions.

https://wow.gamepedia.com/SecureActionButtonTemplate
  Reply With Quote
02-25-19, 12:14 AM   #6
wille480
A Wyrmkin Dreamwalker
Join Date: Jan 2017
Posts: 56
Originally Posted by Fizzlemizz View Post
It would be best if you actually describe what you are trying to do or what effect it is you see in ElvUI that you are trying to duplicate. As far as I know ElvUI doesn't have Target("Phred") function.
I making sort of a group box window where members in a raid will lie inside as frames (buttons). When clicking on a frame, i am retreiving the GetName() function from the frame and then proceed to call that name ingame as a target. But since TargetUnit is peotected, i am not able to target this player in game. What could i do? Kind regards
  Reply With Quote
02-25-19, 12:16 AM   #7
wille480
A Wyrmkin Dreamwalker
Join Date: Jan 2017
Posts: 56
Originally Posted by elcius View Post
you need to create your frame as a secure action button, and then bind it with either the "target" or "macro" actions.

https://wow.gamepedia.com/SecureActionButtonTemplate
That was something i was looking for! Appriciate it
  Reply With Quote
02-25-19, 11:19 AM   #8
Fizzlemizz
I did that?
 
Fizzlemizz's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Dec 2011
Posts: 1,006
This is done by the game where each of your "sub-frame" unit buttons is created by inheriting from the SecureUnitButtonTemplate. Once you've done that, when you click on a unit, the game will make it your target.

The basics of creating a unit button is:

Lua Code:
  1. --Create the unit button:
  2. local f = CreateFrame("Button", "wille480PlayerFrame", UIParent, "SecureUnitButtonTemplate")
  3.  
  4. -- Tell it which unit to represent (in this case "player":
  5. f:SetAttribute("unit", "player")
  6.  
  7. -- Tell the game to "look after it"
  8. RegisterUnitWatch(f)
  9.  
  10. -- Tell it to show the unit's vehicle when the unit is in one:
  11. f:SetAttribute("toggleForVehicle", true)
  12.  
  13. -- Give it the standard click actions:
  14. f:RegisterForClicks("AnyUp")
  15. f:SetAttribute("*type1", "target") -- Target unit on left click
  16. f:SetAttribute("*type2", "togglemenu") -- Toggle units menu on left click
  17. f:SetAttribute("*type3", "assist") -- On middle click, target the target of the clicked unit
  18.  
  19. -- Make it visible for testing purposes:
  20. f:SetPoint("CENTER")
  21. f:SetSize(100, 100)
  22. f:SetBackdrop({ bgFile = "Interface\\BUTTONS\\WHITE8X8" })
  23. f:SetBackdropColor(0.3, 0.3, 0.3, 0.6)
  24.  
  25. -- Then add other objects (such as font strings and status bars), register events (such as UNIT_HEALTH), and add scripts to update the objects in response to the events.

Obviously it needs other "plumbing like health/power bars/texts etc. but that is all up to you as to what you add/leave out from each unit.

If you are looking for a simple (as can be) example of putting this together into a raid frame type configuration using secure group templates , take a loot at ShotGlass
__________________
Fizzlemizz
Maintainer of Discord Unit Frames and Discord Art.
Author of FauxMazzle, FauxMazzleHUD and Move Pad Plus.

Last edited by Fizzlemizz : 02-25-19 at 11:56 AM.
  Reply With Quote
02-25-19, 01:04 PM   #9
Seerah
Fishing Trainer
 
Seerah's Avatar
WoWInterface Super Mod
Featured
Join Date: Oct 2006
Posts: 10,572
If all you would like to accomplish is your own custom layout of unit frames, you can use the oUF framework rather than starting from scratch.
__________________
"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

WoWInterface » AddOns, Compilations, Macros » AddOn Help/Support » Access protected functions? TargetUnit?

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