1. Hello,

    Im trying to work out table with dictionaries problem.

    What Im trying to do is making an addon were I track my dps with certain weapons.

    I have come this far: Made a table with tables in it but lacks a key, which should be the itemLink from the weapon.

          dpsStatus = {}
           dpsStatus.player_damage = {}     -- Stores the players damage
           dpsStatus.combat_time = {}       -- Stores the players time in combat
    

    The second problem is how to put in the information in the tables. This I have tried with this code:

     for idx, vapen in pairs(itemLink) do
            dpsStatus.combat_time[itemLink].damage = dpsStatus.player_damage[itemLink]
        end
    

    Dont know if this is right, I have tried debugging it with printing the table but nothing is printed with:

    for i,v in pairs(dpsStatus.player_damage) do print(i,v) end

    Would really appreciate some help.

  2. Hello,

    Im trying to work out table with dictionaries problem.

    What Im trying to do is making an addon were I track my dps with certain weapons.

    I have come this far: Made a table with tables in it but lacks a key, which should be the itemLink from the weapon.

          dpsStatus = {}
           dpsStatus.player_damage = {}       -- Stores the players damage
           dpsStatus.combat_time = {}     -- Stores the players time in combat
    

    The second problem is how to put in the information in the tables. This I have tried with this code:

     for idx, vapen in pairs(itemLink) do
          dpsStatus.combat_time[itemLink].damage = dpsStatus.player_damage[itemLink]
      end
    

    This will not work, because dpsStatus.combat_time[itemLink] does not return a table, it is just nil. You can have as many sub-tables as you'd like, but you need to ensure each level exists before moving on. Without the rest of the code its difficult to say what precisely is going on. Here's what I would do, roughly:

    Dont know if this is right, I have tried debugging it with printing the table but nothing is printed with:

    for i,v in pairs(dpsStatus.player_damage) do print(i,v) end

    Would really appreciate some help.

     dpsStatus = {
       player_damage = {},
       combat_time = {},
     }
    
     -- When something happens and you need to add something to do the player_damage table:
     if not dpsStatus.player_damage[itemLink] then
       dpsStatus.player_damage[itemLink] = {}
     end
    
     dpsStatus.player_damage[itemLink].damage = someValue
    

    You'd use the same general technique for the other tables, and the other members. Without having a better specification of the problem it is very tough to be more specific.

  3. Hi and thanks for the speedy response :)

    Implemented the changes but cant really say if it made any difference.

    But I supplied some documentation: Lua-file xml-file Screenshot

  4. Unfortunately I'm not sure what I'm supposed to be looking at. Do you have a question?

  5. Hello,

    Yes I got a question.

    For instance, how can I write the current weapon used to be the key in the dictionary table?

    I have made alot of rewrite to the tables.

     evaluationTable = {}
     evaluationTable[weapon] = {}
     evaluationTable[weapon].damage = 0
     evaluationTable[weapon].time = 0
    

    I use this piece of code to get the link of what I got in my mainhand:

     slotId = GetInventorySlotInfo("MainHandSlot")
     itemLink = GetInventoryItemLink("player", slotId)
    

    I have tried just using weapon = itemLink but I get an error that the value is nil. But that be might due to I put in the wrong function in my addon.

    Makes this any sense?

    Thanks again!

  6. Hello,

    Yes I got a question.

    For instance, how can I write the current weapon used to be the key in the dictionary table?

    I have made alot of rewrite to the tables.

     evaluationTable = {}
     evaluationTable[weapon] = {}
     evaluationTable[weapon].damage = 0
     evaluationTable[weapon].time = 0
    

    I use this piece of code to get the link of what I got in my mainhand:

     slotId = GetInventorySlotInfo("MainHandSlot")
     itemLink = GetInventoryItemLink("player", slotId)
    

    I have tried just using weapon = itemLink but I get an error that the value is nil. But that be might due to I put in the wrong function in my addon.

    Where do you want to store it? Just:

     evaluationTable[itemLink] = {}
    

    Is there a reason that doesn't work?

  7. Yes, that do work but I had to move the itemLink variable outside of the in combat dps calculation function. And thus I lose the ability to update the button which shows the current weapon used. However there is surely a way to make that work again but really dont know how.

    http://pastebin.com/0X7GLLvr

  8. I'm really not sure I understand the question or the problem at all. Why can't you just store the last seen item link as a different variable and then use that to update the button text"

  9. I need to update the value of the weapon every time I equip a new weapon.

    I've tried with http://wowprogramming.com/docs/api/IsEquippedItem

    If I register the event and update the value of the weapon every time the fire so it should work. I have tried it like this.

          isEquipped = IsEquippedItem(itemID) or IsEquippedItem("itemName") or IsEquippedItem("itemLink")
    
       if not IsEquippedItem(weapon) == weapon then
          weapon = GetInventorySlotInfo("MainHandSlot")
       end
    

    But I dont get it to work.

  10. I need to update the value of the weapon every time I equip a new weapon.

    I've tried with http://wowprogramming.com/docs/api/IsEquippedItem

    If I register the event and update the value of the weapon every time the fire so it should work. I have tried it like this.

          
          isEquipped = IsEquippedItem(itemID) or IsEquippedItem("itemName") or IsEquippedItem("itemLink")
       
       if not IsEquippedItem(weapon) == weapon then
          weapon = GetInventorySlotInfo("MainHandSlot")
       end
    

    But I dont get it to work.

    This code doesn't make sense. IsEquippedItem() is a function that takes a single argument (either an itemId, an itemName or an itemLink and returns a boolean value. So comparing the result of IsEquippedItem() to weapon is meaningless..

     if not IsEquippedItem(weapon) then
       weapon = GetInventorySlotInfo("MainHandSlot")
     end
    
  11. Used the code:

     if not IsEquippedItem(weapon) then
       weapon = GetInventorySlotInfo("MainHandSlot")
     end
    

    When I swap weapon an error appears saying "attempt to index field '?' (a nil value)", which I guess because 'weapon' gets set to nil and cant put that in the table.

  12. That's all code I dont' see that you've posted.. so I'm not sure what to tell you =)