Thread Tools Display Modes
08-02-08, 07:09 PM   #1
LBXZero
A Theradrim Guardian
AddOn Author - Click to view addons
Join Date: Jul 2008
Posts: 61
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.

Last edited by LBXZero : 08-02-08 at 07:38 PM.
  Reply With Quote
08-03-08, 04:19 AM   #2
xConStruct
A Chromatic Dragonspawn
 
xConStruct's Avatar
AddOn Author - Click to view addons
Join Date: May 2008
Posts: 199
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
  Reply With Quote
08-03-08, 10:09 AM   #3
LBXZero
A Theradrim Guardian
AddOn Author - Click to view addons
Join Date: Jul 2008
Posts: 61
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.
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » Trying to pass a value to a function table

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