|
4 | 4 |
|
5 | 5 | function do_plugin_check_now (id, name)
|
6 | 6 |
|
7 |
| - if IsPluginInstalled (id) then |
8 |
| - return -- all is well |
9 |
| - end -- plugin is installed |
10 |
| - |
11 |
| - ColourNote ("white", "green", "Plugin '" .. name .. "' not installed. Attempting to install it...") |
12 |
| - LoadPlugin (GetPluginInfo(GetPluginID (), 20) .. name .. ".xml") |
13 |
| - |
14 |
| - if IsPluginInstalled (id) then |
15 |
| - ColourNote ("white", "green", "Success!") |
16 |
| - return -- all is well ... now |
17 |
| - end -- plugin is installed |
18 |
| - |
19 |
| - ColourNote ("white", "red", string.rep ("-", 80)) |
20 |
| - ColourNote ("white", "red", "Plugin '" .. name .. "' not installed. Please download and install it.") |
21 |
| - ColourNote ("white", "red", "It is required for the correct operation of the " .. |
22 |
| - GetPluginName () .. " plugin.") |
23 |
| - ColourNote ("white", "red", string.rep ("-", 80)) |
24 |
| - |
| 7 | + local me |
| 8 | + local location |
| 9 | + |
| 10 | + -- allow for being called from main world script |
| 11 | + if GetPluginID () == "" then |
| 12 | + me = "world script" |
| 13 | + location = GetInfo (60) |
| 14 | + else |
| 15 | + me = GetPluginName () .. " plugin" |
| 16 | + location = GetPluginInfo(GetPluginID (), 20) |
| 17 | + end -- if |
| 18 | + |
| 19 | + -- first check if installed |
| 20 | + if not IsPluginInstalled (id) then |
| 21 | + ColourNote ("white", "green", "Plugin '" .. name .. "' not installed. Attempting to install it...") |
| 22 | + LoadPlugin (location .. name .. ".xml") |
| 23 | + |
| 24 | + if IsPluginInstalled (id) then |
| 25 | + 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 |
| 41 | + |
| 42 | + -- here if still not installed |
| 43 | + else |
| 44 | + ColourNote ("white", "red", string.rep ("-", 80)) |
| 45 | + ColourNote ("white", "red", "Plugin '" .. name .. "' not installed. Please download and install it.") |
| 46 | + ColourNote ("white", "red", "It is required for the correct operation of the " .. me) |
| 47 | + ColourNote ("white", "red", string.rep ("-", 80)) |
| 48 | + end -- if not installed |
| 49 | + end -- plugin was not installed |
| 50 | + |
25 | 51 | end -- do_plugin_check_now
|
26 | 52 |
|
27 | 53 |
|
28 |
| - |
29 | 54 | function checkplugin (id, name)
|
| 55 | + |
| 56 | + if GetOption ("enable_timers") ~= 1 then |
| 57 | + ColourNote ("white", "red", "WARNING! Timers not enabled. Plugin dependency checks will not work properly.") |
| 58 | + end -- if timers disabled |
| 59 | + |
30 | 60 | -- give them time to load
|
31 | 61 | DoAfterSpecial (2,
|
32 | 62 | "do_plugin_check_now ('" .. id .. "', '" .. name .. "')",
|
|
0 commit comments