LoTROInterface

LoTROInterface (https://www.lotrointerface.com/forums/index.php)
-   Lua Programming Help (L) (https://www.lotrointerface.com/forums/forumdisplay.php?f=50)
-   -   Prevent a window from being draggable. (https://www.lotrointerface.com/forums/showthread.php?t=1102)

SanDBoX 10-02-2010 05:50 AM

Another thing to note is the main file gives you a great place to instance and access your classes (or windows) that way you have one place where you can see what all your windows are doing and how they are diffrent. It also gives you the ability to pass one instance into another or compare data between them, or create a class whithin a class (such as a subwindow).

I found that most of my "real" logic ended up in main so that it could access and pull data from everywhere and my window classes had minimal logic, mostly just layout.

Olenn 10-02-2010 08:27 AM

Wow, thanks DU, that should be stickied.

I guess that my problem is this;

When I add this to SetupWindow.lua

Code:


        self.sp:AddItem(self.hdr);
        self.sicHolder=Turbine.UI.Control();
        self.sicHolder:SetSize(280,30);
       
        self.locked = Olenn.DUInterface.CheckBox();
        self.locked:SetChecked(false);
        self.locked:SetText("Satchel locked");
        self.locked:SetParent(self.sicHolder);
        self.locked:SetPosition(-112,0);
        self.sp:AddItem(self.sicHolder);

and this to SatchelWindow.lua

Code:


          self.moveBlocker=Turbine.UI.Window();
        self.moveBlocker:SetParent(self);
          self.moveBlocker:SetSize(self:GetWidth() - 25,35);
        self.moveBlocker:SetPosition(0,0);
        self.moveBlocker:SetZOrder(20);
          self.moveBlocker:SetMouseVisible(false);

Everythings good, but obiviously I haven't done anything yet, but when I add this;

Code:

if ( SetupWindow.locked:IsChecked(true) ) then
    self.moveBlocker:SetMouseVisible(true);
else
    self.moveBlocker:SetMouseVisible(false);
end

I get this;

...Rings Online\Plugins\Olenn\Satchel\SatchelWindow.lua:51: attempt to index field 'locked' (a nil value)

It would seem to me that SetupWindow.locked should point to that in the SetupWindow.lua.

Now, I am obviously missing something because I completely ignored the line that you wrote about adding a conditional. I am not even quite sure what a conditional is. I have been digging through lua.org, though, I just haven't been successful yet.

Digital_Utopia 10-02-2010 09:04 AM

Quote:

Originally Posted by Olenn (Post 5063)
Wow, thanks DU, that should be stickied.

I guess that my problem is this;

When I add this to SetupWindow.lua

Code:


        self.sp:AddItem(self.hdr);
        self.sicHolder=Turbine.UI.Control();
        self.sicHolder:SetSize(280,30);
       
        self.locked = Olenn.DUInterface.CheckBox();
        self.locked:SetChecked(false);
        self.locked:SetText("Satchel locked");
        self.locked:SetParent(self.sicHolder);
        self.locked:SetPosition(-112,0);
        self.sp:AddItem(self.sicHolder);

and this to SatchelWindow.lua

Code:


          self.moveBlocker=Turbine.UI.Window();
        self.moveBlocker:SetParent(self);
          self.moveBlocker:SetSize(self:GetWidth() - 25,35);
        self.moveBlocker:SetPosition(0,0);
        self.moveBlocker:SetZOrder(20);
          self.moveBlocker:SetMouseVisible(false);

Everythings good, but obiviously I haven't done anything yet, but when I add this;

Code:

if ( SetupWindow.locked:IsChecked(true) ) then
    self.moveBlocker:SetMouseVisible(true);
else
    self.moveBlocker:SetMouseVisible(false);
end

I get this;

...Rings Online\Plugins\Olenn\Satchel\SatchelWindow.lua:51: attempt to index field 'locked' (a nil value)

It would seem to me that SetupWindow.locked should point to that in the SetupWindow.lua.

Now, I am obviously missing something because I completely ignored the line that you wrote about adding a conditional. I am not even quite sure what a conditional is. I have been digging through lua.org, though, I just haven't been successful yet.

A conditional is an if/else statement - doing something on the condition that something else is true/false

but basically what the problem is that you need to start off in Main declaring an instance of both SetupWindow and SatchelWindow, and do your if/then/else within that: eg:

in Main.lua
Code:

setWindow = SetupWindow();
satWindow = SatchelWindow();

setWindow.locked.CheckChanged=function(sender,args)

if ( setWindow.locked:IsChecked(true) ) then
    satWindow.moveBlocker:SetMouseVisible(true);
else
    satWindow.moveBlocker:SetMouseVisible(false);
end

end


Olenn 10-02-2010 03:04 PM

Okay, I think I understand everything, and I am pretty sure that I have everything where is is supposed to go. I just got the error;

...d of the Rings Online\Plugins\Olenn\Satchel\Main.lua:63: attempt to call method 'IsChecked' (a boolean value)

I know that a boolean in a 'true / false' statement, but what is this error trying to tell me?

Oh yeah, the line it is calling is;

Code:

61    SetupWindow.locked.CheckChanged=function(sender,args)
62
63    if ( SetupWindow.locked:IsChecked(true) ) then
64          SatchelWindow.moveBlocker:SetMouseVisible(true);
65    else
66          SatchelWindow.moveBlocker:SetMouseVisible(false);
67    end
68
69    end



All times are GMT -5. The time now is 09:44 PM.

vBulletin® - Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
© MMOUI