Thread Tools Display Modes
03-04-13, 07:08 PM   #1
Clamsoda
A Frostmaul Preserver
Join Date: Nov 2011
Posts: 269
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 07:49 PM.
  Reply With Quote
03-04-13, 08:16 PM   #2
Dridzt
A Pyroguard Emberseer
 
Dridzt's Avatar
AddOn Author - Click to view addons
Join Date: Nov 2005
Posts: 1,359
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)
  Reply With Quote
03-04-13, 08:39 PM   #3
Clamsoda
A Frostmaul Preserver
Join Date: Nov 2011
Posts: 269
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 09:01 PM.
  Reply With Quote

WoWInterface » 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