View Single Post
10-21-14, 11:02 AM   #1
sirann
A Flamescale Wyrmkin
Join Date: Mar 2007
Posts: 142
Efficient Table Wiping

Good afternoon, I'm creating a function that will essentially, every 2.6s, determine how many targets have been hit by blade flurry. The text value will update every .25s, but every 2.6s the table will wipe to ensure the value is as accurate as possible with mobs moving in/out of range or dying.

This is dry coded, so I don't even know if this works, my main question revolves on methods of efficiently clearing all the table keys and values of bladeflurrytargets, is table.wipe() the best option? At the very most, I would expect <20 keys and values in the table at a time. Would it be more efficient to do a k,v delete?

Lua Code:
  1. local bftcf = CreateFrame('Button', 'BladeFlurryTargetCountFrame', UIParent)
  2.         bftcf:SetSize(50,50)
  3.         bftcf:SetPoint('CENTER', UIParent, 'CENTER')
  4.     local bftcftext = bftcf:CreateFontString(nil, 'OVERLAY')
  5.         bftcftext:SetFont(FONTSTRINGHERE, 11, 'OUTLINE')
  6.         bftcftext:SetAllPoints()
  7.        
  8.         bftcf:SetScript('OnUpdate', function(self, elapsed, bladeflurrytargets)
  9.             if (elapsed > 0.25 and < 2.6) then --update the text value every 1/4 second to give ~real time analysis
  10.                 bftcftext:SetText(#bladeflurrytargets)
  11.             elseif elapsed >= 2.6 then  --update every main hand attack base line speed interval(way faster than this with slice and dice, but just to make sure) to be sure every target that's going to be hit has been hit
  12.                 bftcftext:SetText(#bladeflurrytargets)
  13.                 table.wipe(bladeflurrytargets)
  14.                 elapsed = 0
  15.             end
  16.         end)
  Reply With Quote