Reply
 
Thread Tools Display Modes
Old 06-23-2009, 10:07 AM   #1
ChaosInc
Curse staff
 
ChaosInc's Avatar
Interface Author - Click to view interfaces
Join Date: Aug 2006
Posts: 414
Checking for and hooking scripts?

Took a stab in the dark and failed miserably. So here I am again.

Code:
for k,_ in pairs(activeProfile) do
				if _G[k].OnShow ~= nil then
					print("Debug: ".. k.. ".OnShow found!")
					origOnShow = _G[k].OnShow
					_G[k].OnShow = CFM_ShowHook
				end
				CFM_ApplySettings(k)
			end
I haven't the foggiest on how to accomplish this. To elaborate, I'm trying to do a check if a frame has an OnShow script, and if so, hook into it with my function. Reason I want to do this is because users trying to modify LoD frames (such as the vehicle bar, I like to shrink mine personally) won't see any changes when the frame actually shows up unless they go in and do a quick setting change while the frame is visible.
__________________
I acknowledge and accept the consequences of my actions. I apologize for NOTHING.

"Introduce a little anarchy. Upset the established order, and everything becomes chaos. I'm an agent of chaos. Oh, and you know the thing about chaos? It's fair!" -- The Joker
ChaosInc is offline   Reply With Quote
Old 06-23-2009, 10:25 AM   #2
Cargor
A Flamescale Wyrmkin
 
Cargor's Avatar
Interface Author - Click to view interfaces
Join Date: May 2008
Posts: 142
Script handlers are not stored inside the object, but you can use frame:GetScript("OnShow") to get the function. There's also the function frame:HookScript(script, func) which does exactly the same as hooksecurefunc only for scripts.
If you want to overwrite the old script-function instead of just hooking in it after, you can use SetScript of course

I wrote a simple function for some of my addons which use HookScript or SetScript based on whether the frame already has a script, maybe you'll find it useful

Code:
local function hookScript(self, script, func)
	if(self:GetScript(script)) then
		self:HookScript(script, func)
	else
		self:SetScript(script, func)
	end
end
__________________
« Homepage | Git »

Oh hai!
Cargor is offline   Reply With Quote
Old 07-06-2009, 04:12 PM   #3
ChaosInc
Curse staff
 
ChaosInc's Avatar
Interface Author - Click to view interfaces
Join Date: Aug 2006
Posts: 414
Thanks mate. Exactly what I needed.
__________________
I acknowledge and accept the consequences of my actions. I apologize for NOTHING.

"Introduce a little anarchy. Upset the established order, and everything becomes chaos. I'm an agent of chaos. Oh, and you know the thing about chaos? It's fair!" -- The Joker
ChaosInc is offline   Reply With Quote
Reply

Go BackWoWInterface » Developer Discussions » Lua Script help » Checking for and hooking scripts?

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




The Network:
EQInterface | EQ2Interface | LoTROInterface | MMOInterface | War.MMOUI | WoWInterface | VGInterface | Allakhazam | Thottbot | Wowhead | Zam


©2009 MMOUI / ZAM Network
vBulletin - Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.