An OnPluginListChanged question

Posted by Twisol on Sun 03 Jan 2010 05:40 AM — 5 posts, 14,812 views.

USA #0
I'm messing around with some plugin dependency things right now, and a bit of an issue came up. The plugin I'm working on currently depends on the ATCP plugin, and when the plugin list changes (i.e. after all plugins are guaranteed to be loaded), I use CallPlugin() to call a function defined in the ATCP plugin.

The issue is that I can't see any unobtrusive way to -only- run the CallPlugin() when it's the ATCP plugin that's just been (re)installed. Right now, it's called whenever any plugin is reinstalled, which isn't exactly something I'd like happening.

Would anyone happen to have any suggestions on how to get around this? In case it's useful, here's the OnPluginListChanged I'm using:

OnPluginListChanged = function()
  local atcp = PPI.Load("7c08e2961c5e20e5bdbf7fc5")
  if not atcp then
    error("ATCP plugin not installed. Please install the ATCP plugin, then reinstall this plugin.")
  end
  _G["atcp"] = atcp
  
  atcp.EnableModule("room_brief")
end


(If you're wondering, PPI is a library script I wrote to encapsulate some inter-plugin communication. It's related to my previous LoadPPI, except it uses CallPlugin() directly, and doesn't have the load-on-demand functionality.)
Amended on Sun 03 Jan 2010 05:42 AM by Twisol
Australia Forum Administrator #1
Just so I understand the question, are you saying that if plugins A, B and C were previously installed, and then B was reinstalled, you want a way of knowing that B has changed but not A or C?

I don't know if it would help, but B itself would know if it had been reinstalled.

In other words, your ATCP plugin could detect if an attempt was made to EnableModule twice for some module (or any module) by keeping track of whether it had been enabled before in a table.
USA #2
Sure, but if you did something much less repeatable - for example, sending something to the world - then it's undesirable no matter how you look at it.

B itself knows it's been reinstalled, and could certainly send a broadcast message to interested parties... but then we're back to square one, before OnPluginListChanged was implemented. =/
Australia Forum Administrator #3
I have added selector 22 to GetPluginInfo. This is the date/time the plugin was installed (to the nearest second).

Thus any plugin can store that information for any other plugin. If the date/time of the target plugin changes, then that plugin has been reinstalled.
USA #4
Ahh, great! Thanks, Nick.