Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6589853
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T17:13:38+00:00 2026-05-25T17:13:38+00:00

I’m trying to create a simple addon for world of warcraft which records my

  • 0

I’m trying to create a simple addon for world of warcraft which records my kills.
I’ve already got’n quite far except there is a problem with the writing of a lua array.

The code I have so far

local CharacterDefaults = { 
    kills = {},
    totalkills = 0
}
local killDefaults = {
    DBtimeofday = 0,
    DBplayer = 0,
    DBenemyname = 0,
    DBenemyid = 0,
    DBzone = 0,
    DBkilltype = 0
}

The next piece is inside a event which checks for overkill

if not KillCount then
    KillCount = CharacterDefaults
end         

if not KillCount.totalkills then
    KillCount.totalkills = 0
end 
KillCount.enemy[KillCount.totalkills] = destName                        
KillCount.kills[KillCount.totalkills] = killDefaults 
KillCount.kills[KillCount.totalkills].DBtimeofday = stamp
KillCount.kills[KillCount.totalkills].DBzone = zone 
KillCount.kills[KillCount.totalkills].DBkilltype = killtype 
KillCount.kills[KillCount.totalkills].DBenemyid = unitId 
KillCount.kills[KillCount.totalkills].DBenemyname = destName 
KillCount.kills[KillCount.totalkills].DBplayer = playerName 
KillCount.totalkills = KillCount.totalkills + 1 

Ofcourse there’s more code but this is the only important code (as far as I know).

If I look at this I would expect that for every new kill a new array part is made and the values are entered. However, for each kill I make in world of warcraft, every single item already in it will get the results of the last kill.

The lua variables saved file:

KillCount = {
    ["kills"] = {
        {
            ["DBplayer"] = "MyName",
            ["DBzone"] = "Blackrock Depths",
            ["DBkilltype"] = 0,
            ["DBenemyname"] = "Grim Patron",
            ["DBenemyid"] = 9545,
            ["DBtimeofday"] = "11-09-22 10:45:23",
        }, -- [1]
        {
            ["DBplayer"] = "MyName",
            ["DBzone"] = "Blackrock Depths",
            ["DBkilltype"] = 0,
            ["DBenemyname"] = "Grim Patron",
            ["DBenemyid"] = 9545,
            ["DBtimeofday"] = "11-09-22 10:45:23",
        }, -- [2]
        [0] = {
            ["DBplayer"] = "MyName",
            ["DBzone"] = "Blackrock Depths",
            ["DBkilltype"] = 0,
            ["DBenemyname"] = "Grim Patron",
            ["DBenemyid"] = 9545,
            ["DBtimeofday"] = "11-09-22 10:45:23",
        },
    },
    ["totalkills"] = 3,
}

as you can see the [0] is the only one to be properly writen. Am I doing something wrong?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T17:13:39+00:00Added an answer on May 25, 2026 at 5:13 pm

    The problem is here:

    KillCount.kills[KillCount.totalkills] = killDefaults
    

    Everytime you kill, you’re pointing KillCount.kills[KillCount.totalkills] to killDefaults then modifying killDefaults. The problem is, you are using the same killDefaults every time. So when you udpate the values of killDefaults later, it affects every reference to killDefaults that you have already created.

    Try something like:

    function GetDefaultKills()
        return {
            DBtimeofday = 0,
            DBplayer = 0,
            DBenemyname = 0,
            DBenemyid = 0,
            DBzone = 0,
            DBkilltype = 0
        };
    end
    
    KillCount.kills[KillCount.totalkills] = GetDefaultKills()
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Basically, what I'm trying to create is a page of div tags, each has
I am trying to understand how to use SyndicationItem to display feed which is
I'm trying to select an H1 element which is the second-child in its group
I'm trying to convert HTML to plain text. I get many &\#8217; &\#8220; etc.
I'm trying to create an if statement in PHP that prevents a single post
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and
I used javascript for loading a picture on my website depending on which small
I am trying to find ID3V2 tags from MP3 file using jid3lib in Java.
I've got a string that has curly quotes in it. I'd like to replace

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.