Munk,
Thank you for the feedback. I've seen others use
Lua Code:
frame:SetScript("OnEvent", function(self, event, ...)
if self[event] then
self[event](self, ...)
end
end)
And I get the concept of how it works, but I don't truly understand the syntax. My understanding is this: we see if the event is a table key of our function table with
. If this passes, then it runs a function that has the same name as the event.
Later in the code you name the function like:
Lua Code:
function frame:PLAYER_ENTERING_WORLD(...)
-- code
end
but wouldn't this create a global function as there's no local before the function? Or is it still localized because that function is bound to (in this case) the STF frame from the initial SetScript?
Additionally, I don't understand how you would upvalue a table value. I understand that an upvalue look up is faster than a table look up, especially three table look ups, I just don't fully grasp how you would do it.
Thank you for everyone's comments and feedback. It has been very helpful.