View Single Post
09/14/14, 09:55 PM   #4
Sasky
AddOn Author - Click to view addons
Join Date: Apr 2014
Posts: 231
Originally Posted by merlight View Post
And the 3) point is what doesn't make any sense to me. What was the reasoning behind making :New add __index to the class, and not add it straight in :Subclass?
Even though they are stored in the same structure in Lua, it looks like they're trying to differentiate between class (or prototype) and object. If they assume an object is always instantiated from the class then used (and not the prototype/subclass definition used directly), :New() is always called and it works fine.

Lua Code:
  1. PrototypeMovableStats = ZO_Stats:Subclass()
  2. MovableStatsInstance = PrototypeMovableStats:New()

Personally, I'd probably use the alternate method I mentioned above: just define your functions directly on STATS itself. It's the same thing in effect without messing around with metatables (and is slightly more efficient).
  Reply With Quote