View Single Post
11-28-10, 03:51 PM   #5
Mischback
A Cobalt Mageweaver
 
Mischback's Avatar
AddOn Author - Click to view addons
Join Date: Aug 2009
Posts: 221
No, it will not be working this way...

What you can do, is the following:

Inside of your class-specific files, you create a function to do all the stuff.
Then you can call this class-specific function in your if-statement in the main-file.

The "hunter-file":
lua Code:
  1. local ADDON, ns = ...
  2.  
  3. ns.hunteropt = function()
  4.     -- do hunter stuff here
  5. end

Main-file:
lua Code:
  1. local ADDON, ns = ...
  2.  
  3. aframes = CreateFrame("Frame", nil, UIParent)
  4. aframes:SetScript("OnEvent", function(self, event, ...) self[event](self, event, ...) end)
  5. aframes:RegisterEvent("PLAYER_ENTERING_WORLD")
  6. local playerClass = FreeUI.playerClass
  7. local f=CreateFrame("Frame")
  8. aframes:SetScript("OnEvent", function(self, event, ...)
  9.         local inv = PLAYER_ENTERING_WORLD
  10.         if playerClass == "HUNTER" then
  11.            ns.hunterop()
  12.         end
  13. end)

What is happening is: The hunter-specific function is seperated in an own file, but inserted into the namespace of the addon, so you can use it in your main file.
In the main file, this function is called.

I wouldn't do it that way, but it should work.
__________________
  Reply With Quote