Reply
 
Thread Tools Display Modes
Old 03-04-13, 06:08 PM   #1
Clamsoda
A Cobalt Mageweaver
Join Date: Nov 2011
Posts: 239
Passing additional arguments when hooking scripts

Good evening,

I am curious if there is a method for passing additional arguments to the function of a script hook, other than those that are specific to that script.

The scripts in particular are OnMessageScrollChanged and OnShow. I'd like to pass a variable to the function, but I don't see any way of defining that variable.

Code:
frame:HookScript("OnMessageScrollChanged", bottomButtonControl(Here))
frame:HookScript("OnShow", bottomButtonControl(Here))
Thank you for the help!

Edit: I have thought of a solution for my problem: defining the variable outside of the function, and just setting it, rather than defining and setting it inside of the function. This will eliminate the need to pass the variable as an argument to the HookScript's function, but I am still curious if it is possible.

Last edited by Clamsoda : 03-04-13 at 06:49 PM.
Clamsoda is offline   Reply With Quote
Old 03-04-13, 07:16 PM   #2
Dridzt
A Pyroguard Emberseer
 
Dridzt's Avatar
AddOn Author - Click to view addons
Join Date: Nov 2005
Posts: 1,190
Not when you're passing the function variable directly but you can do it with an anonymous function 'wrapper' ie
Code:
frame:HookScript("OnMessageScrollChanged", function(self) bottomButtonControl(Here) end)
frame:HookScript("OnShow", function(self) bottomButtonControl(There) end)
Dridzt is online now   Reply With Quote
Old 03-04-13, 07:39 PM   #3
Clamsoda
A Cobalt Mageweaver
Join Date: Nov 2011
Posts: 239
Somehow I knew it was going to be so freaking simple =/.

Thank you Dridzt.

Edit: Worked perfectly, thank you.

Last edited by Clamsoda : 03-04-13 at 08:01 PM.
Clamsoda is offline   Reply With Quote
Reply

Go BackWoWInterface » Developer Discussions » Lua/XML Help » Passing additional arguments when 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