We have detected that cookies are not enabled on your browser. Please enable cookies to ensure the proper experience.
Results 1 to 3 of 3
  1. #1
    Join Date
    Apr 2013
    Posts
    42

    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:
    Code:
    PluginLoader=class(Turbine.UI.Control);
    function PluginLoader:Constructor()
    	Turbine.UI.Control.Constructor(self);
    	self.loaded=false;
    	self.pluginName = plugin:GetName();
    	self:SetWantsUpdates(true);
    	
    	self.Update=function()
    		if (Plugins[self.pluginName] ~= nil) and (not self.loaded) then
    			local parentName = string.gsub (self.pluginName, "Loader$", "");
    Turbine.Shell.WriteLine ("Reloading "..parentName);			
    			self.loaded=true;
    			self:SetWantsUpdates(false);
    			Turbine.PluginManager.UnloadScriptState(parentName);
    			Turbine.PluginManager.LoadPlugin(parentName);
    		end		
    	end
    end
    loaderControl=PluginLoader();
    A few slight changes:
    -- 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:
    Turbine.PluginManager.UnloadSc riptState(parentName);
    Turbine.PluginManager.LoadPlug in(parentName);
    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!


    ???

  2. #2
    Join Date
    Mar 2007
    Posts
    1,590
    First, a small clarification. You don't unload a Plugin, you unload a ScriptState which is an entire environment that includes one or more plugins. Turbine's Lua allows multiple copies of the Lua environment. A plugin normally runs in the default environment but can be loaded into a distinct copy by defining the "Apartment" property of the "Configuration" tag in the .plugin file. So, to be unloaded programmatically, the plugin should have it's own apartment and that is the name that is passed to the UnloadScriptState method. I'm not sure, but it's likely that you are trying to unload the plugin rather than it's apartment. There is a more detailed description in the Party Sample post in the Writing LotRO Lua Plugins for Noobs thread:
    https://www.lotro.com/forums/showthr...12#post5839512

  3. #3
    Join Date
    Apr 2013
    Posts
    42

    d'oh

    ah... that was it, after a fashion.

    The plugin and apartment had the same name ... or would have, if there hadn't been a subtle typo in the apartment name. Meaning it couldn't find the apartment to unload, since I was apparently too dense to type in the name properly.

    *sigh*


    ... on to discover my next lu-bie troubles ...


 

 

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

This form's session has expired. You need to reload the page.

Reload