Another Slash Command
Sorry for my bad english in this post, but i am a german guy. So i hope you will understand me :9
Okay. Here is my addon: krahlog.lua Code:
local function klog(args) And the saved variables looks like: Code:
KRAHLog_raidmembers = { I have do delete it by hand, and that is not in my opinion :( I have to: Code:
"/klog save" Code:
"klog delete" Code:
KRAHLog_raidmembers = { |
Okay. I was working on it, but i does not work :(
Here is my current code snipped: Code:
function saveLogfile() How can i add my code that i posted abouve, that this addon save and delete some variables ? |
I assume you have tables listed in your TOC SavedVariables or SavedVariablesPerCharacter line ?
If so, the game automatically saves the values you store in those tables when you log out. And automatically loads them when you log in. The simplest way to clear the table is to set it to {}. So if your SavedVariable table was MySavedTable then you would do MySavedTable = {} to clear out the contents ready for adding new data to. When you want to write to the table you would then do MySavedtable = MySavedTable or {} to use the loaded table or create a new one if it doesn't exist yet. Then whatever you add to it will get saved. Remember though that if you wish to add another table to it you may need to repeat the process above for the sub table. EG. MySavedTable[subTable] = MySavedTable[subTable] or {} Otherwise simply writing MySavedTable.SavedVariable = SomeValue and MySavedTable[subTable].SubTableVariable = AnotherValue will mean it will get written to the WTF file. |
Also, looking at your code I think you may want to change things slightly there:
Code:
local function handler(msg) |
Okay. I will try it.
But how can i delete the strings? Code:
KRAHLog_raidmembers = { I will delete this subtable: Code:
["25.05.10 14:44:16"] = { |
Yes that will empty the table in its entirety. Your WTF file after typing /rlog delete will be
Code:
KRAHLog_raidmembers = { EG: Code:
KRAHLog_raidmembers = { Which reminds me .. the other way to wipe a table is to actually use the command wipe(tableName). |
Code:
local function handler(msg) |
Hmm, well the last 2 lines I got from your code as I assumed the slash command function was being reached.
This is how I code for slash commands if my addon name is called ScrollingWatchFrame I am assuming that your TOC file contains KRAHLog_raidmembers as a saved variable table. Add a print("blah text") line to make sure it gets to where you want. Code:
local function ValidateSlashCommand(msg) Code:
SLASH_ScrollingWatchFrameCmd1 = '/swf'; You may have to change the yellow items to reflect your addon but that should all work the way you want. If it doesn't try the wipe(KRAHLog_raidmembers) instead and see if that works. I am doing this from memory but I do know wipe(table) works as I use it in one of my own addons. The function converts what you type into lower case so the case is not an issue here. With my example /swf delete should trigger the slash command test and empty the table. Simply changing the yellow items to your addons values should be enough. |
Yes.
My toc file hast: ## SavedVariables: KRAHLog_raidmembers at the top of the line |
I'm not too familiar with Lua yet, but if I understood what you want to do with your addon, this should do it (I only changed your slash command, the rest of the code can stay as is):
Code:
... On /klog save it will call your klog() function to save the data, and print out a msg in chat that it's saved. On /klog delete it will empty the table in SavedVars. Hope it helps. |
If you are wanting to clear the sub tables then you will need to pass the ID for the table in something like this;
Code:
local function ValidateSlashCommand(msg) /klog delete 25.05.10 14:44:16 thats completely untest but basically u define the ID you want and then set it to nil to remove it from the main table. Ideally you would have a better ID, rather than using the date/time. a better structure might be; Code:
KRAHLog_raidmembers = { I think your best option though is to look into a UI component that will give you a list of raids and a button to click to delete (which stores the ID etc in it) |
All times are GMT -6. The time now is 05:39 PM. |
vBulletin © 2024, Jelsoft Enterprises Ltd
© 2004 - 2022 MMOUI