Thread: Slash commands
View Single Post
04-03-09, 02:05 PM   #4
p3lim
A Pyroguard Emberseer
 
p3lim's Avatar
AddOn Author - Click to view addons
Join Date: Feb 2007
Posts: 1,710
Both are usable, I use a bit different system to handle my savedvariables.
Here is an example from pMinimap:

Code:
local defaults = {
	one = true,
	two = false,
	three = 'test',
}

local function LoadDefaults()
	pMinimapDB = pMinimapDB or {}
	for k,v in next, defaults do
		if(type(pMinimapDB[k]) == 'nil') then
			pMinimapDB[k] = v
		end
	end
end

local function SlashHandler(str)
	if(str == 'reset') then
		pMinimapDB = nil
		LoadDefaults()
		print'savedvariables reset'
	else
		-- whatever
	end
end

SLASH_PMINIMAP1 = '/pmm'
SlashCmdList.PMINIMAP = SlashHandler
Works quite well, it allows for defaults to be set, even when adding new entries.

I also put in a sample of my slashhandler
  Reply With Quote