Skip to content

Commit

Permalink
Changed checkplugin to also check plugin enabled
Browse files Browse the repository at this point in the history
  • Loading branch information
nickgammon committed May 28, 2011
1 parent 5334bac commit 3e147b1
Showing 1 changed file with 49 additions and 19 deletions.
68 changes: 49 additions & 19 deletions lua/checkplugin.lua
Original file line number Diff line number Diff line change
Expand Up @@ -4,29 +4,59 @@

function do_plugin_check_now (id, name)

if IsPluginInstalled (id) then
return -- all is well
end -- plugin is installed

ColourNote ("white", "green", "Plugin '" .. name .. "' not installed. Attempting to install it...")
LoadPlugin (GetPluginInfo(GetPluginID (), 20) .. name .. ".xml")

if IsPluginInstalled (id) then
ColourNote ("white", "green", "Success!")
return -- all is well ... now
end -- plugin is installed

ColourNote ("white", "red", string.rep ("-", 80))
ColourNote ("white", "red", "Plugin '" .. name .. "' not installed. Please download and install it.")
ColourNote ("white", "red", "It is required for the correct operation of the " ..
GetPluginName () .. " plugin.")
ColourNote ("white", "red", string.rep ("-", 80))

local me
local location

-- allow for being called from main world script
if GetPluginID () == "" then
me = "world script"
location = GetInfo (60)
else
me = GetPluginName () .. " plugin"
location = GetPluginInfo(GetPluginID (), 20)
end -- if

-- first check if installed
if not IsPluginInstalled (id) then
ColourNote ("white", "green", "Plugin '" .. name .. "' not installed. Attempting to install it...")
LoadPlugin (location .. name .. ".xml")

if IsPluginInstalled (id) then
ColourNote ("white", "green", "Success!")

-- now make sure enabled (suggested by Fiendish - version 4.74+ )

if not GetPluginInfo(id, 17) then
ColourNote ("white", "green", "Plugin '" .. name .. "' not enabled. Attempting to enable it...")
EnablePlugin(id, true)
if GetPluginInfo(id, 17) then
ColourNote ("white", "green", "Success!")
else
ColourNote ("white", "red", string.rep ("-", 80))
ColourNote ("white", "red", "Plugin '" .. name .. "' not enabled. Please make sure it can be enabled.")
ColourNote ("white", "red", "It is required for the correct operation of the " .. me)
ColourNote ("white", "red", string.rep ("-", 80))
end -- if
end -- if not enabled

-- here if still not installed
else
ColourNote ("white", "red", string.rep ("-", 80))
ColourNote ("white", "red", "Plugin '" .. name .. "' not installed. Please download and install it.")
ColourNote ("white", "red", "It is required for the correct operation of the " .. me)
ColourNote ("white", "red", string.rep ("-", 80))
end -- if not installed
end -- plugin was not installed

end -- do_plugin_check_now



function checkplugin (id, name)

if GetOption ("enable_timers") ~= 1 then
ColourNote ("white", "red", "WARNING! Timers not enabled. Plugin dependency checks will not work properly.")
end -- if timers disabled

-- give them time to load
DoAfterSpecial (2,
"do_plugin_check_now ('" .. id .. "', '" .. name .. "')",
Expand Down

0 comments on commit 3e147b1

Please sign in to comment.