Originally Posted by Resike
[...]
Then why cant i make the function local?
Also why cant call the function like that with the SetScript?
|
Because your syntax is wrong. You can not set a script handler using the syntactic colon operator. SetScript/HookScript expect a reference to a function. Using the colon is just a shorter way of passing the table as the first argument:
lua Code:
local someaddon = {a = 10, plus = function(self) self.a = self.a + 5 end}
someaddon:plus(5)
print(someaddon.a) -- prints 15
local addonb = {a = 30, plus = someaddon.plus}
addonb:plus(10)
print(addonb.a) -- prints 40
someaddon.plus(addonb, 5)
print(someaddon.a) -- prints 20
print(addonb.a) -- prints 40