The re-load trick (Moormap etc) ... having trouble
Okay, so I've got the helper plugin set up to reload. I can invoke it from within my 'main' plugin; it is successfully called and runs.
What does *not* appear to be happening is that my main plugins isn't receiving an 'unload' directive.
I've got a WriteLine command in my Unload() function which __isn't called__ when the re-loader runs, so I can be certain that the plugin's Unload() command isn't being invoked.
Here is my loader plugin's code, which is based on the MoorMapLoader code:
A few slight changes:
self.pluginName = plugin:GetName();
if (Plugins[self.pluginName] ~= nil) and (not self.loaded) then
local parentName = string.gsub (self.pluginName, "Loader$", "");
Turbine.Shell.WriteLine ("Reloading "..parentName);
-- I've based it on Control (which also gets updates) rather than window, since window is a child object of control, and uses up more data/memory.
-- I've generalized this code [so it can be reused without change in any plugin] by pulling the reloading plugin's name from the environment at loading-time, then assuming that a plugin called <Name>Loader is the reloader plugin for a plugin called <Name>. This works - the debugging WriteLine call shows it has deduced 'parentName' properly. Also, for debugging, I tried replacing 'parentName' in those calls with the explicit 'main' plugin name, and the behavior remained the same.
So I'm a bit baffled.
I thought all that was required to force the PluginManager to unload and then reload a plugin was those two calls:
And I know that the Reloader makes it into that block of code, and that it accurately computes parentName.
And yet, that parent plugin isn't getting unloaded.
The upshot is that my main plugin correctly puts itself into the "i'm about to be reloaded" state, and successfully calls the reloader... and then doesn't get reloaded!
If I manually unload (/plugins unload all) and then reload my main plugin, it reloads in the "I'm being reloaded" state and behaves appropriately.
So everything seems to be working *except* that the Loader plugin, though successfully invoked, does not unload/reload my main plugin!