View Full Version : Possible to call local functions?
xTwoStepx
28-09-2006, 11:36 PM
Is it possible to too call a local function in another addon?
include
29-09-2006, 12:42 AM
??? how the name sais: "local"...
so NO, other addons could not use these functions.
you have to reload the functions in the other addons (including the lua-file or copypaste your function)
xTwoStepx
29-09-2006, 07:25 AM
I figured. I was just hoping you could call it using an object based call. Like MyAddon:MyLocalFunction.
Is there a benefit making function in your addon private like that? other than not allowing outside addons share your functions?
vallerius
04-10-2006, 12:41 AM
The benefit is that you don't pollute the namespace with your functions. If I had a non-local function in my mod called DoSomethingFancy, the name DoSomethingFancy is now taken for every other mod out there. If someone else tried to use the same function name, the results would be unpredictable.
This is why you often see addons using prefixes on the beginnings of their functions and variables, to try to avoid collisions like this. Using local is the better solution though, assuming the function isn't intended to be called from a different file (if a function is local it's local to the lua file it's in, not to the addon).
vBulletin® v3.8.4, Copyright ©2000-2009, Jelsoft Enterprises Ltd.