Quantcast new at this/looking for assist - WoWInterface
Thread Tools Display Modes
10-05-19, 07:01 AM   #1
jadiilelz
A Defias Bandit
Join Date: Oct 2019
Posts: 2
Question new at this/looking for assist

hi all
i'm new to lua and to wow api dev in general and have one question about... SetPoint and hooksecurefunc

i figure most people reading this will already know what i'm asking but here it goes!

i have this project for my personal ui

- i am hoping you all know of a way around the issue here but basically i keep getting an error
tried to call the protected function 'TargetFrame:SetPoint()'.
you will see a line in the core.lua script that mentions 'filthy hack'
- this was added to stop the error from happening after a lot of failed tests which prevented securely updating the position, such as the following; which was ultimately removed since it doesn't solve anything

Code:
local f = _G['TargetFrame']

hooksecurefunc( f, 'SetPoint', function( self )

  --TargetFrameHealthBar:SetStatusBarColor( 1,0,1 )
  --hooksecurefunc( f, 'PlayerFrame_ResetPosition', function( self )

  local _ap, _, _relp, _x = self:GetPoint( )

  if _ap ~= frame_settings.target.anchor_point or _relp ~= frame_settings.target.relative_point or jlelz:round( tonumber( _x ) ) ~= frame_settings.target.x then

    self:ClearAllPoints()

    self:SetPoint( frame_settings.target.anchor_point, UIParent, frame_settings.target.relative_point, frame_settings.target.x, frame_settings.target.y )

  end

end )
i attempted to update the code.. a few times, in hopes i'd eventually understand the nuances of something like hooksecurefunc to get past this issue to no avail. if you all have any tips, i'd be grateful <3

thank you!

Last edited by jadiilelz : 10-05-19 at 02:11 PM. Reason: clarity
  Reply With Quote
10-05-19, 09:18 AM   #2
d87
A Flamescale Wyrmkin
 
d87's Avatar
AddOn Author - Click to view addons
Join Date: Jan 2006
Posts: 144
You can't move unit frames in combat.

And nowadays you can reposition default player and target frames without any addons
  Reply With Quote
10-05-19, 09:23 AM   #3
aallkkaa
A Warpwood Thunder Caller
 
aallkkaa's Avatar
AddOn Author - Click to view addons
Join Date: Jun 2017
Posts: 90
Well, on your "filthy hack" snippet, you are trying to reset the methods :ClearAllPoints and :SetPoint of protected frames ('PlayerFrame', 'TargetFrame', etc), which is never a good idea, as other addons might need to use those methods as well; actually Blizzard might need to use those methods on their frames as well - and that's why they're protected.

And, as the error message you got implied, even using those methods (let alone modify the methods themselves) on protected frames doesn't go very well with Blizzard, particularly in combat.

There are some things you can do with the standard Blizzard frames, but usually only out of combat (rhis restriction is to prevent automation such as the game casting spell A or B in response to world events, without user interaction, AKA having the game play itself for you).
Not saying this is what you're trying to do (hardly looked at your code). But the above is something to keep in mind.

You can listen to the event PLAYER_REGEN_DISABLED to listen for player entering combat. PLAYER_REGEN_ENABLED lets you listen for player leaving combat. InCombatLockdown() returns true when you are in combat, and thus prevented from messing with protected frames.
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » new at this/looking for assist

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