OK .... so after much trial and error, I've hit a wall. I successfully set up all of my conditionals to check to see if my target is the unit type I want, grab the target's name, and check to see if the emote used is the one that I want to track.
I store the target's name into a variable, and I am attempting to use the name variable as a key in a table, and then the value for that key is numerical. I'm pretty sure that I'm going about this wrong, as when I attempt to add the value to the table, and then immediately print() it, I get no output. The error is most likely something simple in my for loop syntax, but I can't seem to figure out what I am doing wrong.
Lua Code:
--Create the table
bonktrack = {}
local emotetype, btname
local function btracker(token)
emotetype = token
--print(emotetype)
btname = GetUnitName("target", true)
tartype = UnitIsPlayer("target")
--print(tartype)
--print(btname)
if tartype == true then
if btname ~= nil then
if emotetype == "BONK" then
--print("Success")
for k, v in pairs(bonktrack) do
if bonktrack[btname] then
bonktrack[btname] = bonktrack[btname] + 1
print(bonktrack[btname] .. " Added")
else
table.insert(btname, 1)
print(bonktrack[btname] .. " Init")
end
end
else
print("BONK fail")
end
else
print("btname fail")
end
else
print("Not a player or no target")
end
end
hooksecurefunc("DoEmote", btracker)