Just a question...

Hey powerful guys!,

it’s jsut a little question today:
why should we write some local function?
like:
local function Disablenoclip()

thanks !


(User was banned for this post ("Undescriptive thread title; wrong section" - mahalis))

You should always use local unless there’s a really good reason a variable has to be global. If you have some functions in your addons that need to be accessible from multiple files (quite common), consider using a single global table with all of your addon’s functions as members. For example:

[lua]myaddon = {}

function myaddon.EnableFoo()
– code
end

function myaddon.MakePlayerFly( ply )
– code
end[/lua]

Because if we made our function the global MakePlayerFly, and the admin mod was also badly coded and also created a function with that same name, your function would be overwritten. It also takes more time to look up and call global functions.