View Single Post
03/03/16, 11:33 AM   #10
Wandamey
Guest
Posts: n/a
Originally Posted by merlight View Post
SMITHING, that's the instance ...
... of class ZO_Smithing, a subclass ...
... of class ZO_Smithing_Common, a subclass ...
... of ZO_Object

When SMITHING:OnSelectedPatternChanged() is called, Lua looks for "OnSelectedPatternChanged" key
first in the "self" table you called it on -> SMITHING
if it's not there, it looks in the class -> ZO_Smithing
if it's not there, it looks in the base -> ZO_Smithing_Common
and so on

You can put your hooks anywhere in the hierarchy -- sometimes that's necessary, for example when there are many objects of a class, that are created on the fly, and you want to change the behaviour of all of them, past and future -- you replace methods in the class. But hooks higher in the hierarchy overrule base class hooks (more precisely that's because of how ZO_PreHook works; you could write a hook that honors base class overrides, but nobody does that). For singleton objects that are hooked by various add-ons it's best to hook on the singleton, highest level, so that your hooks aren't overruled.
When I think I was happy to just not have a nil error for the function I wanted to pick

I think I get it, if what you call "higher" in the hierarchy is the first checked? otherwise i may need to sleep on it. Like a whole year.
For now i'll just stick to this : "try a table first".
  Reply With Quote