Thanks for taking time to read this, in advance.
I’m wanting to know if making changes to a variable that references a table will affect the table the variable is referencing, or if the variable becomes a separate dynamic value.
local damage = {}
function module:AddDamage(p1, p2, amt)
local d = damage[p2]; d = d or {}
d[p1] = (d[p1] or 0) + amt
end
I’m using this function to track the amount of damage players take so as to reward kill credit to the player that dealt the most damage to them. I create the variable ‘d’ as a reference to Player2’s damage log, setting it to a blank table if one doesn’t exist. I then reference Player1’s entry in P2’s damage log and create a new one if one doesn’t already exist, then add the specified amount to the entry.
What I’d like to know is, will making changes to ‘d’ affect the original ‘damage’ table, or do I need to manually set ‘damage’ to ‘d’?