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
    Sep 2010
    Location
    Springfield, IL
    Posts
    7

    Question Plugin script state "HelloWorld" could not be unloaded.

    I'm just getting started learning Lua -- still at the "Hello World" stage -- but I've run into a problem that makes testing difficult. I can't figure out how to unload my plugin so that I can load a new version for testing.

    When I type '/plugins unload HelloWorld', I get the error message 'Plugin script state "HelloWorld" could not be unloaded.' I have an apartment specified in my .plugin file, which I thought would take care of the problem, but still no joy.

    Code:
    <?xml version="1.0"?>
    <Plugin>
        <Information>
            <Name>HelloWorld</Name>
            <Author>Dag</Author>
            <Version>1.00</Version>
            <Description>Learning LOTRO Lua scripting.</Description>
            <Image>Dag/HelloWorld/icon.jpg</Image>
        </Information>
        <Package>Dag.HelloWorld.Main</Package>
        <Configuration Apartment="DagsPlace" />
    </Plugin>

    The code isn't doing anything fancy, just opening 3 windows with some text in them. It's taken pretty much verbatim from Garan's excellent tutorial.

    Code:
    import "Turbine";
    import "Turbine.UI";
    import "Turbine.UI.Lotro";
    HelloWindow=class(Turbine.UI.Lotro.Window)
    
    function HelloWindow:Constructor(x,y)
    
      if x==nil or y==nil then
        x=Turbine.UI.Display:GetWidth()/2-100;
        y=Turbine.UI.Display:GetHeight()/2-100;
      end
    
      Turbine.UI.Lotro.Window.Constructor(self);
    
      -- override the built in SetPosition, adding a simple output statement.
      self.SetPosition=function(sender, left, top)
        Turbine.UI.Window.SetPosition(self, left, top); -- pass the args on to the base class built in function
        Turbine.Shell.WriteLine("You positioned this instance at ("..tostring(left)..","..tostring(top)..")");
        -- perform some additional code here
      end
    
      self:SetSize(200,200);
      self:SetPosition(x,y);
      self:SetText("Hello World Window");
      self.Message=Turbine.UI.Label();
      self.Message:SetParent(self);
      self.Message:SetSize(180,20);
      self.Message:SetPosition(10,90);
      self.Message:SetTextAlignment(Turbine.UI.ContentAlignment.MiddleCenter);
      self.Message:SetText("Hello World");
      self:SetVisible(true);
     end
    
    window1=HelloWindow(10,40);
    window2=HelloWindow();
    window3=HelloWindow(40,200);

    If someone could point me in the right direction, I'd really appreciate it. Thanks!
    [charsig=http://lotrosigs.level3.turbine.com/0b20c0000001a2a49/01008/signature.png]undefined[/charsig]

  2. #2
    Join Date
    Mar 2007
    Posts
    1,190
    You don't unload an individual plugin. You unload its Apartment (which unloads ALL plugins in that apartment). Since you named your Apartment "DagsPlace" then you would use "/plugins unload DagsPlace". I believe the apartment is actually case insensitive.

    Bear in mind that every Apartment gets its own global environment which means it occupies a lot more memory than if it coexisted with other plugins. Given the current issues surrounding the client's misuse of memory (lots of memory leaks in the client and lots of crashes due to referencing memory that is no longer allocated) it is probably best to leave the apartment blank and just use "/plugins unload" to unload all plugins. Even if you do use event handlers, as long as you use the AddCallback and RemoveCallback methods you will be able to safely coexist with other plugins that also use Add/RemoveCallback and can exist in their apartment just fine thus saving a lot of memory. If your plugin gets complex enough to have issues/conflicts with other plugins then it's worth running in your own apartment.
    Last edited by Garan; Dec 01 2012 at 02:51 PM.

  3. #3
    Join Date
    Sep 2010
    Location
    Springfield, IL
    Posts
    7
    Quote Originally Posted by Garan View Post
    You don't unload an individual plugin. You unload its Apartment (which unloads ALL plugins in that apartment). Since you named your Apartment "DagsPlace" then you would use "/plugins unload DagsPlace".
    Doh! That should've been obvious. And to think that I deliberately named the apartment to be different from the name of the plugin because I thought it would reduce confusion. Thanks for the help!

    Quote Originally Posted by Garan View Post
    it is probably best to leave the apartment blank and just use "/plugins unload" to unload all plugins.
    I was just thinking that I would have it in its own apartment while I'm in this early stage of learning, to make it easier for me to unload/reload while I'm testing, without needing to unload all of the other plugins that I use. Thanks for the advice, though! I'll definitely keep that in mind as I move forward.
    [charsig=http://lotrosigs.level3.turbine.com/0b20c0000001a2a49/01008/signature.png]undefined[/charsig]

 

 

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