Quantcast
WoWInterface - View Single Post - Attempting to track emotes performed on targets.
View Single Post
03-29-18, 07:56 PM   #3
briskman3000
A Black Drake
AddOn Author - Click to view addons
Join Date: Mar 2009
Posts: 83
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:
  1. --Create the table
  2. bonktrack = {}
  3.  
  4. local emotetype, btname
  5.  
  6. local function btracker(token)
  7.     emotetype = token
  8.     --print(emotetype)
  9.     btname = GetUnitName("target", true)
  10.     tartype = UnitIsPlayer("target")
  11.     --print(tartype)
  12.     --print(btname)
  13.     if tartype == true then
  14.         if btname ~= nil then
  15.             if emotetype == "BONK" then
  16.                 --print("Success")
  17.                 for k, v in pairs(bonktrack) do
  18.                     if bonktrack[btname] then
  19.                         bonktrack[btname] = bonktrack[btname] + 1
  20.                         print(bonktrack[btname] .. " Added")
  21.                     else
  22.                         table.insert(btname, 1)
  23.                         print(bonktrack[btname] .. " Init")
  24.                     end
  25.                 end
  26.             else
  27.                 print("BONK fail")
  28.             end
  29.         else
  30.             print("btname fail")
  31.         end
  32.     else
  33.         print("Not a player or no target")
  34.     end
  35. end
  36. hooksecurefunc("DoEmote", btracker)
  Reply With Quote