View Single Post
04-07-13, 05:32 AM   #12
Resike
A Pyroguard Emberseer
AddOn Author - Click to view addons
Join Date: Mar 2010
Posts: 1,290
Originally Posted by Phanx View Post
Just use dot notation instead of colon notation to avoid confusion:
I saw other addons use the : notation so thats why i choose this one too.

Originally Posted by Phanx View Post
The (probably more sensible) alternative would be to define script handlers directly in the SetScript call:

Code:
PVPSoundEffectSoundEngineFrame:SetScript("OnUpdate", function(self, elapsed)
     -- stuff goes on here
end)
The only reason to define the script handler function separately would be if you planned to call the same function from other places, or you wanted multiple frames to use the same event handler function, etc.
My current onupdate handler looks like this now:

Code:
local PVPSoundEffectSoundEngineFrame = CreateFrame("Frame", "PVPSoundEffectSoundEngineFrame")
local TimeSinceLastEffectUpdate = 0

function PVPSound:UpdateSoundEffectEngine(elapsed)
	if PS_EnableAddon == true then
		if PS_SoundEffect == true then
			TimeSinceLastEffectUpdate = TimeSinceLastEffectUpdate + elapsed
			while TimeSinceLastEffectUpdate > PVPSound_NextEffectUpdate do
				TimeSinceLastEffectUpdate = TimeSinceLastEffectUpdate - PVPSound_NextEffectUpdate
				PVPSound_NextEffectUpdate = PVPSound:PlayNextSoundEffect()
			end
		end
	end
end

PVPSoundEffectSoundEngineFrame:SetScript("OnUpdate", PVPSound.UpdateSoundEffectEngine)
But i have like 10 of em in my addon, and i might want to mergre them later.

Originally Posted by Phanx View Post
Also, when you set a list of variables with the same name, when you're done, there is only one copy of the variable, and it contains the last value set:

Code:
local var, var, var, var = 1, 2, "cat", "dog"
print(var) -> "dog"
So:

Code:
function object:method(self)
    print(self)
end
object:method("lolcats") -> "lolcats"
I see but since it only overwrites nearly nothing in my case, then i should be fine or not?
  Reply With Quote