Quantcast Fixing up an abandoned addon - WoWInterface
Thread Tools Display Modes
08-17-18, 09:26 AM   #1
Puddycat
A Kobold Labourer
Join Date: Aug 2018
Posts: 1
Fixing up an abandoned addon

Hi, I am trying to update an addon that was abandoned in 2011.
It was working till patch 8.0 though.

I think there are 2 main problems.
SetText doesn't seem to be sending over any text.

Code:
autoMacroOptionsTitle:SetText(autoMacroStrings.Title);
And I am not sure it is reading all the channels.
My debuff only shows channel

Code:
function ChannelsMenu_Initialize()
	local channels = { GetChannelList(); }
	local channels_user = {};
	local iter = 0;
	for i,title in ipairs(channels) do
		if i % 2 ~= 0 then
			iter = iter + 1;
			channels_user[iter] = title;
		else
			channels_user[iter] = channels_user[iter] .. ". " .. title;
			ShowDebug("Found channel " .. channels_user[iter]);
		end
	end
	for i, title in ipairs(channels_user) do
		local info = UIDropDownMenu_CreateInfo();
		info.text = title;
		info.value = i;
		info.owner = ChannelsDropdown;
		info.func = function(self) OnChannelsMenuClick(self) end;
		UIDropDownMenu_AddButton(info);
	end
end

function OnChannelsMenuClick(self)
	UIDropDownMenu_SetSelectedValue(self.owner, self.value);
	local menuText = UIDropDownMenu_GetText(ChannelsDropdown);
	ShowDebug("Selected channel: [" .. self.value .. "] : " .. menuText);
	autoMacroOptionsChannelButton:SetText(menuText);
end
I have uploaded the entire addon to Github aswell: https://github.com/DamienShahan/autoMacro/tree/master

I would greatly appreciate any help.
  Reply With Quote
08-23-18, 06:34 AM   #2
PhoenixPower
A Defias Bandit
Join Date: Aug 2011
Posts: 3
Lightbulb

The reason why the code is erroring is that GetChannelList() now returns 3 values per channel rather than 2. Also changed to a recursive style, adding another if statement with a modulus comparison seemed ugly. And I don't think anything is wrong with the SetText code, it just never got executed because it happens after the error trying to initialize the dropdown menu. Just replace the original ChannelsMenu_Initialize with this one and you should be good to go.

Lua Code:
  1. function ChannelsMenu_Initialize()
  2.     local function AddChannelsRecursively(id, name, disabled, ...)
  3.         local title = id .. ". " .. name;
  4.         ShowDebug("Found channel " .. title);
  5.  
  6.         local info = UIDropDownMenu_CreateInfo();
  7.         info.text = title;
  8.         info.value = id;
  9.         info.owner = ChannelsDropdown;
  10.         info.func = OnChannelsMenuClick;
  11.         UIDropDownMenu_AddButton(info);
  12.  
  13.         if ... then return AddChannelsRecursively(...) end
  14.     end
  15.     AddChannelsRecursively(GetChannelList());
  16. end

Last edited by PhoenixPower : 08-23-18 at 06:44 AM.
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » Fixing up an abandoned addon

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