View Single Post
07-24-13, 12:20 AM   #19
Niketa
A Wyrmkin Dreamwalker
 
Niketa's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2013
Posts: 54
Originally Posted by semlar View Post
The other thing is you didn't localize nmlmethod or nmlthreshold so they become global variables which you generally want to avoid on the off-chance you overwrite something.
I set nmlmethod and nmlthreshold as global so I could access them for different events (because I need to be able to retrieve these values on LOOT_OPENED to revert the settings). What would a better approach be?


Originally Posted by Phanx View Post
Code:
events:SetScript("OnEvent", function(self, event, ...)
   -- automatically call the method for this event, if it exists
   return self[event] and self[event](self, event, ...)
end)
I don't understand the code here that you've used to call the function. I'm assuming "self[event]" would refer to events and whatever the event is and "(self, event, ...)" is just what it is?

Originally Posted by Phanx View Post
Add this in the main chunk of your file, outside of any function, and before you set your OnEvent script:

Code:
local mobIDFromGUID = setmetatable({}, { __index = function(t, guid)
   local mobID = tonumber(strsub(guid, 6, 10), 16)
   t[guid] = mobID
   return mobID
end })
I'm not sure where the "t" comes from in the code. Is it just an alias for the table where "function(t, guid)" is essentially "function(self,parameter)" or something along those lines?


I'm still reworking the code with your suggestions so I won't post quite yet, but I will either before I go to bed or after work tomorrow.

Last edited by Niketa : 07-24-13 at 01:21 AM.
  Reply With Quote