View Single Post
05-18-10, 08:33 AM   #5
Fodaro
A Cyclonian
 
Fodaro's Avatar
AddOn Author - Click to view addons
Join Date: Dec 2008
Posts: 42
I think it depends how many options you want to have. Consolid8 (my chat addon) just has a few, so I use slash commands. The simplified handler goes something like this:
Code:
SlashCmdList["CONSOLID"] = function(msg)
	msg = string.lower(msg)
	if msg == "report" then
		Consolid8.Report()
	elseif msg == "show" then
		Consolid8.Show()
	-- ...
	else
		print("Command not recognized.")
	end
end
If you have a lot of commands, you may wish to use a table, e.g.:
Code:
switches = {
	report = Consolid8.Report,
	show = Consolid8.Show,
	-- ...
}

SlashCmdList["CONSOLID"] = function(msg)
	msg = string.lower(msg)
	if switches[msg] then
		switches[msg](msg)
	else
		print("Command not recognized.").
	end
end
To use the interface options, it's just a case of creating a frame and using an API function to register it, although I haven't done it personally.
__________________
Fodaro
(Main: Fodaro-Bronzebeard (EU))
Author of CharNote and Consolid8
  Reply With Quote