From 0277d3bab762ee792b719cc172c4743b4a6487e8 Mon Sep 17 00:00:00 2001 From: yago Date: Sun, 5 Apr 2015 16:27:04 +0200 Subject: [PATCH] Locals on plugins --- plugins/plugins.lua | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/plugins/plugins.lua b/plugins/plugins.lua index 021c41b..35d4bf8 100644 --- a/plugins/plugins.lua +++ b/plugins/plugins.lua @@ -1,4 +1,6 @@ -function enable_plugin( filename ) +do + +local function enable_plugin( filename ) -- Check if plugin is enabled if plugin_enabled(filename) then return 'Plugin '..filename..' is enabled' @@ -15,7 +17,7 @@ function enable_plugin( filename ) end end -function disable_plugin( name ) +local function disable_plugin( name ) -- Check if plugins exists if not plugin_exists(name) then return 'Plugin '..name..' does not exists' @@ -31,14 +33,14 @@ function disable_plugin( name ) return reload_plugins(true) end -function reload_plugins( ) +local function reload_plugins( ) plugins = {} load_plugins() return list_plugins(true) end -- Retruns the key (index) in the config.enabled_plugins table -function plugin_enabled( name ) +local function plugin_enabled( name ) for k,v in pairs(_config.enabled_plugins) do if name == v then return k @@ -49,7 +51,7 @@ function plugin_enabled( name ) end -- Returns true if file exists in plugins folder -function plugin_exists( name ) +local function plugin_exists( name ) for k,v in pairs(plugins_names()) do if name..'.lua' == v then return true @@ -58,7 +60,7 @@ function plugin_exists( name ) return false end -function list_plugins(only_enabled) +local function list_plugins(only_enabled) local text = '' for k, v in pairs( plugins_names( )) do -- ✔ enabled, ❌ disabled @@ -78,7 +80,7 @@ function list_plugins(only_enabled) return text end -function run(msg, matches) +local function run(msg, matches) -- Show the available plugins if matches[1] == '!plugins' then return list_plugins() @@ -113,4 +115,6 @@ return { "^!plugins? (reload)$" }, run = run, privileged = true -} \ No newline at end of file +} + +end \ No newline at end of file