Slash commands
I want to start using slash commands and storing some values in the WTF folder. Has someone any good links on this topic? What I want to know is how to save values and how to re-read them from the WTF folder at the next login.
|
There are quite a few ways of doing it, but this is what I do.
Add a saved Variables field to the toc: Code:
## SavedVariables: MyAddonSV ie. Code:
local eframe = CreateFrame("Frame") |
I've always been using VARIABLES_LOADED.
|
Both are usable, I use a bit different system to handle my savedvariables.
Here is an example from pMinimap: Code:
local defaults = { I also put in a sample of my slashhandler |
Quote:
Also as a slight aside I couldn't help but notice this Quote:
Quote:
|
Quote:
Code:
for k, v in next, defaults do Code:
if(type(pMinimapDB[k]) == 'nil') then if so, proceed to add the default settings. |
Quote:
Code:
if pMinimapDB[k] == nil then But I digress. |
Not sure if you saw or not, it checks the default table, matches it with my savedvariable.
using 'if(v == nil) then' wouldnt result in anything, because nothing in the default table is nil. again: Code:
for k, v in next, defaults do |
Quote:
I meant Code:
pMinimapDB[k] == nil |
Quote:
The reason why I used type() was because we've already discussed this in a different topic, and it seemed to work, so Ive used it ever since. Anyways, this has driven off topic quite a bit. |
A thing I started to do recently was to, instead of populating the users saved variables with the defaults from a table, I would just set the __index metatable to the default table, much easier.
Code:
local function LoadDefaults() |
You might also like to take a look at how to set up slash commands:
Code:
SlashCmdList["ParaUISlashCOMMAND"] = function(msg) |
All times are GMT -6. The time now is 06:08 PM. |
vBulletin © 2024, Jelsoft Enterprises Ltd
© 2004 - 2022 MMOUI