WoWInterface

WoWInterface (https://www.wowinterface.com/forums/index.php)
-   Lua/XML Help (https://www.wowinterface.com/forums/forumdisplay.php?f=16)
-   -   Trying to pass a value to a function table (https://www.wowinterface.com/forums/showthread.php?t=17511)

LBXZero 08-02-08 07:09 PM

Trying to pass a value to a function table
 
For my mod, I am adding functions to add support for other existing addons. When this mod loads, it checks if the addons exist and adds entries to a table

Code:


(on load code)
...
if (Clique) then
 ADDONS_DETECTED["Clique"] = CSB.Clique
end
...
(on load code)

Then when certain buttons are made, a function is called to go through the list and use every function listed

Code:

function CSB_AddonExtensions( spellButton )
 for index, action in pairs(ADDONS_DETECTED) do
  action(spellButton);
 end       
end

function CSB:Clique( spellButton)
...

My problem is that the spellButton parameter is not being passed to the function addressed in the table, but the function is ran. The parameter does exist in CSB_AddonExtensions function, but it does not exist in the function called from the table.

xConStruct 08-03-08 04:19 AM

Code:

function CSB:Clique( spellButton)
is an alternative notation to
Code:

function CSB.Clique (self, spellButton)
(Notice the colon and single dot)
If you call action(spellButton), the first parameter (self) would take the value of spellButton and the second would be empty.

Try to use:
Code:

action(CSB, spellButton)
This will pass CSB as the self-parameter and spellButton as the (correct) spellButton-parameter.

Hope, this helps :)

LBXZero 08-03-08 10:09 AM

Thanks for the explanation.

I am trying to make my mod be directly compatible with other mods that use the spell book instead of indirectly compatible. For now, Clique will be the first to be adapted and then Trinity Bars because those two came up in some bug problems.

When it comes to crafting an object, I seem to be a perfectionist.


All times are GMT -6. The time now is 11:14 AM.

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