Skip to content

Commit ce50a69

Browse files
committed
Improvements to checkplugin.lua
1 parent a3d3275 commit ce50a69

File tree

1 file changed

+19
-17
lines changed

1 file changed

+19
-17
lines changed

lua/checkplugin.lua

Lines changed: 19 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44

55
function do_plugin_check_now (id, name)
66

7-
local me
8-
local location
7+
local me -- who am I? plugin or main world script?
8+
local location -- location to attempt to load plugin from
99

1010
-- allow for being called from main world script
1111
if GetPluginID () == "" then
@@ -23,31 +23,33 @@ function do_plugin_check_now (id, name)
2323

2424
if IsPluginInstalled (id) then
2525
ColourNote ("white", "green", "Success!")
26-
27-
-- now make sure enabled (suggested by Fiendish - version 4.74+ )
28-
29-
if not GetPluginInfo(id, 17) then
30-
ColourNote ("white", "green", "Plugin '" .. name .. "' not enabled. Attempting to enable it...")
31-
EnablePlugin(id, true)
32-
if GetPluginInfo(id, 17) then
33-
ColourNote ("white", "green", "Success!")
34-
else
35-
ColourNote ("white", "red", string.rep ("-", 80))
36-
ColourNote ("white", "red", "Plugin '" .. name .. "' not enabled. Please make sure it can be enabled.")
37-
ColourNote ("white", "red", "It is required for the correct operation of the " .. me)
38-
ColourNote ("white", "red", string.rep ("-", 80))
39-
end -- if
40-
end -- if not enabled
4126

4227
-- here if still not installed
4328
else
4429
ColourNote ("white", "red", string.rep ("-", 80))
4530
ColourNote ("white", "red", "Plugin '" .. name .. "' not installed. Please download and install it.")
4631
ColourNote ("white", "red", "It is required for the correct operation of the " .. me)
4732
ColourNote ("white", "red", string.rep ("-", 80))
33+
return -- skip enabled check
4834
end -- if not installed
4935
end -- plugin was not installed
5036

37+
38+
-- now make sure enabled (suggested by Fiendish - version 4.74+ )
39+
40+
if not GetPluginInfo(id, 17) then
41+
ColourNote ("white", "green", "Plugin '" .. name .. "' not enabled. Attempting to enable it...")
42+
EnablePlugin(id, true)
43+
if GetPluginInfo(id, 17) then
44+
ColourNote ("white", "green", "Success!")
45+
else
46+
ColourNote ("white", "red", string.rep ("-", 80))
47+
ColourNote ("white", "red", "Plugin '" .. name .. "' not enabled. Please make sure it can be enabled.")
48+
ColourNote ("white", "red", "It is required for the correct operation of the " .. me)
49+
ColourNote ("white", "red", string.rep ("-", 80))
50+
end -- if
51+
end -- if not enabled
52+
5153
end -- do_plugin_check_now
5254

5355

0 commit comments

Comments
 (0)