View Single Post
08-01-14, 07:05 AM   #9
zork
A Pyroguard Emberseer
 
zork's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2008
Posts: 1,740
That setmetatable syntax has always eluded me.

How would I add a new model?

Lua Code:
  1. tinsert(canvas.models,1)

That way?

p.s. I do not create 50 models upfront. That was just for the example.

Additionally. In the end...does the setmetatable syntax produce a different result than this?

Lua Code:
  1. local m = CreateFrame("PlayerModel", nil, canvas)
  2.     m:EnableMouse(true)
  3.  
  4.     m.name = "model"..id
  5.     m.id = id
  6.  
  7.   function m:Reset()
  8.     print(self.name, "resetting values")
  9.     self:PortraitZoom(0)
  10.   end
  11.  
  12.   function m:OnMouseDown(...)
  13.     print(self.name, ...)
  14.     self:Reset()
  15.   end
  16.  
  17.   function m:OnMouseUp(...)
  18.     print(self.name, ...)
  19.   end
  20.  
  21.   m:SetScript("OnMouseDown", m.OnMouseDown)
  22.   m:SetScript("OnMouseUp", m.OnMouseUp)

If not. Why the hassle?
__________________
| Simple is beautiful.
| WoWI AddOns | GitHub | Zork (WoW)

"I wonder what the non-pathetic people are doing tonight?" - Rajesh Koothrappali (The Big Bang Theory)

Last edited by zork : 08-01-14 at 07:24 AM.
  Reply With Quote