View Single Post
05-25-10, 07:51 PM   #11
upyursh
An Aku'mai Servant
AddOn Author - Click to view addons
Join Date: Mar 2009
Posts: 32
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)
       msg = string.lower(msg);
       local args = {};
       for word in string.gmatch(msg,"[^%s]+") do
            table.insert(args,word);
       end
       if ( args[1] == "delete" and args[2] and args[3]) then
          raid_id = args[2] . " " . args[3]
          print("Deleting the contents of KRAHLog_raidmembers[raid_id] which currently has the value of ", KRAHLog_raidmembers[raid_id]);
          KRAHLog_raidmembers[raid_id] = nil
       end
end
you would then run something

/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 = {
  [0] = {
    [date] = "25.05.10 14:44:16",
    [raiders] = {
      "1 05/25/10 Death Knight Baalsabar", -- [1]
      "2 05/25/10 Paladin Taschy", -- [2]
      "3 05/25/10 Warrior Fateoflestat", -- [3]
      "4 05/25/10 Paladin Rögnvaldr", -- [4]
      "5 05/25/10 Druid Cielaroque", -- [5]
      "6 05/25/10 Rogue Maxîros", -- [6]
      "7 05/25/10 Hunter Fiatteen", -- [7]
      "8 05/25/10 Druid Muschka", -- [8]
      "9 05/25/10 Warlock Eawin", -- [9]
      "10 05/25/10 Shaman Kieras", -- [10]
      "11 05/25/10 Paladin Dale", -- [11]
      "12 05/25/10 Warrior Natias", -- [12]
    },
  },
  [1] = {
    [date] = "26.05.10 14:45:00",
    [raiders] = {
      "1 05/26/10 Death Knight Baalsabar", -- [1]
      "2 05/26/10 Paladin Taschy", -- [2]
      "3 05/26/10 Warrior Fateoflestat", -- [3]
      "4 05/26/10 Paladin Rögnvaldr", -- [4]
      "5 05/26/10 Druid Cielaroque", -- [5]
      "6 05/26/10 Rogue Maxîros", -- [6]
      "7 05/26/10 Hunter Fiatteen", -- [7]
      "8 05/26/10 Druid Muschka", -- [8]
      "9 05/26/10 Warlock Eawin", -- [9]
      "10 05/26/10 Shaman Kieras", -- [10]
      "11 05/26/10 Paladin Dale", -- [11]
      "12 05/26/10 Warrior Natias", -- [12]
    },
  },
}
but that's up to u i guess

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)
  Reply With Quote