[Home] [Downloads] [Search] [Help/forum]

Gammon Software Solutions forum

See www.mushclient.com/spam for dealing with forum spam. Please read the MUSHclient FAQ!

[Folder]  Entire forum
-> [Folder]  MUSHclient
. -> [Folder]  Suggestions
. . -> [Subject]  checkplugin.lua should also enable an installed but disabled plugin
Home  |  Users  |  Search  |  FAQ
Username:
Register forum user name
Password:
Forgotten password?
(New message)
Subject: checkplugin.lua should also enable an installed but disabled plugin
Name:
Your forum user name.
Register forum user name
Password:
Your forum password.
Forgotten password?
Message:
Message to be posted (in English, please)
Maximum of 6000 characters. Text only please, no HTML.
Forum codes:
Check this if your message uses 'forum codes' or templates (auto-detected for new posts).
Forum codes Templates

Save this message ...


Subject review (reverse sequence)

Posted by Nick Gammon   Australia  (19,499 posts)  [Biography] bio   Forum Administrator
Date Sun 29 May 2011 03:04 AM (UTC)  quote  ]
Message
Oh, right. I meant *my* "improved" version has a bug. ;)

- Nick Gammon

www.gammon.com.au, www.mushclient.com
[Go to top] top

Posted by Fiendish   USA  (1,010 posts)  [Biography] bio   Global Moderator
Date Sun 29 May 2011 01:56 AM (UTC)  quote  ]

Amended on Sun 29 May 2011 02:00 AM (UTC) by Fiendish

Message
Quote:

Actually your version has a bug. You are checking if it is enabled, even if the install fails.

Err, I don't think so. My version has a return if the plugin isn't installed and trying to install it fails.

http://aardwolfclientpackage.googlecode.com/
https://github.com/fiendish/aardwolfclientpackage
[Go to top] top

Posted by Nick Gammon   Australia  (19,499 posts)  [Biography] bio   Forum Administrator
Date Sat 28 May 2011 11:44 PM (UTC)  quote  ]
Message
Actually your version has a bug. You are checking if it is enabled, even if the install fails. It should read:


function do_plugin_check_now (id, name)

  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


- Nick Gammon

www.gammon.com.au, www.mushclient.com
[Go to top] top

Posted by Nick Gammon   Australia  (19,499 posts)  [Biography] bio   Forum Administrator
Date Sat 28 May 2011 11:41 PM (UTC)  quote  ]
Message
Good idea (I think). I have made a few more improvements too, as follows:


function do_plugin_check_now (id, name)

  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!") 
    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

  -- 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
   
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 .. "')", 
                  sendto.script)
end -- checkplugin


Since checkplugin requires timers to be active, it checks for that. Also do_plugin_check_now will now work from the main script as well as plugins.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
[Go to top] top

Posted by Fiendish   USA  (1,010 posts)  [Biography] bio   Global Moderator
Date Sat 28 May 2011 06:04 PM (UTC)  quote  ]

Amended on Sat 28 May 2011 06:05 PM (UTC) by Fiendish

Message
Currently (4.73) it seems that checkplugin.lua's do_plugin_check_now only checks that a plugin is installed, but doesn't make sure that it is enabled. I think it should also be checking for enabled by changing do_plugin_check_now to


function do_plugin_check_now (id, name)

   if not IsPluginInstalled (id) then
      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!") 
      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 " ..
                    GetPluginName () .. " plugin.")
         ColourNote ("white", "red", string.rep ("-", 80))
         return
      end
   end
   
   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 " ..
                    GetPluginName () .. " plugin.")
         ColourNote ("white", "red", string.rep ("-", 80))        
      end
   end
end -- do_plugin_check_now

http://aardwolfclientpackage.googlecode.com/
https://github.com/fiendish/aardwolfclientpackage
[Go to top] top

The dates and times for posts above are shown in Universal Co-ordinated Time (UTC).

To show them in your local time you can join the forum, and then set the 'time correction' field in your profile to the number of hours difference between your location and UTC time.


1,619 views.

[New subject]  Start a new subject   [Refresh] Refresh page

Go to topic:           Search the forum


[Go to top] top

Quick links: MUSHclient. MUSHclient help. Forum shortcuts. Posting templates. Lua modules. Lua documentation.

[Home]

Written by Nick Gammon - 5K

Comments to: Gammon Software support
[RH click to get RSS URL] Forum RSS feed ( http://www.gammon.com.au/rss/forum.xml )

[Best viewed with any browser - 2K]    [Web site powered by FutureQuest.Net]