View Single Post
04-16-14, 09:30 AM   #5
jeruku
A Cobalt Mageweaver
 
jeruku's Avatar
AddOn Author - Click to view addons
Join Date: Oct 2010
Posts: 223
Perhaps you should use a function to add functions to frames.

For example:
Lua Code:
  1. end
  2. local function DoSomething(self, ...)
  3.    print("Hello")
  4. end
  5. local function DoALittleDance(self, ...)
  6.    print("Bonjour")
  7. end
  8. local function NowDoAHandStand(self, ...)
  9.    print("Aloha")
  10. end
  11. local function AddFunctionsToFrame(self)
  12.      self.func1 = DoSomething
  13.      self.func2 = DoALittleDance
  14.      self.func3 = NowDoAHandStand
  15. end
  16.  
  17. local frame = CreateFrame('Frame')
  18. local frame2 = CreateFrame('Frame')
  19.  
  20. AddFunctionsToFrame(frame)
  21. AddFunctionsToFrame(frame2)



Seeing as you were playing with code here is an example you may have missed.
Lua Code:
  1. local frame = CreateFrame()
  2.  
  3. local function TestFunction()
  4.   print("Hello")
  5. end
  6. print(TestFunction) -- prints the function identifier
  7.  
  8. frame.aFunc= TestFunction
  9. print(frame.aFunc)
  10.  
  11. frame:aFunc()
  12. TestFunction = function()
  13.   print("Goodbye")
  14. end
  15.  
  16. print(TestFunction)
  17. print(frame.aFunc) -- This will print the identifier of the original function
__________________
"I have not failed, I simply found 10,000 ways that did not work." - Thomas Edison
  Reply With Quote