WoWInterface

WoWInterface (https://www.wowinterface.com/forums/index.php)
-   Lua/XML Help (https://www.wowinterface.com/forums/forumdisplay.php?f=16)
-   -   Passing additional arguments when hooking scripts (https://www.wowinterface.com/forums/showthread.php?t=45933)

Clamsoda 03-04-13 07:08 PM

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.

Dridzt 03-04-13 08:16 PM

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)


Clamsoda 03-04-13 08:39 PM

Somehow I knew it was going to be so freaking simple =/.

Thank you Dridzt.

Edit: Worked perfectly, thank you.


All times are GMT -6. The time now is 09:49 AM.

vBulletin © 2024, Jelsoft Enterprises Ltd
© 2004 - 2022 MMOUI