Originally Posted by Seerah
Or this...
Lua Code:
local controlTemplate = { type = "checkbox", name = GetGuildName(GetGuildId(guildIndex)), getFunc = function() ... end, setFunc = function(value) ... end, disabled = function() local guildId = GetGuildId(guildIndex) return not guildId or guildId == 0 end, } local addonOptions = { [1] = controlTemplate, [2] = controlTemplate }
|
This alone won't work. You'd need to set addonOptions[i].name and addonOptions[i].disabled in a loop anyway, otherwise the name would be just empty string, and disabled() would always return true. My mkoptGuildCheckbox() constructor returns a table with .name filled, and more importantly, creates a closure containing guildIndex, so that all functions (getFunc, setFunc, disabled) have guildIndex of the guild they shall work with.