PDA

View Full Version : Prevent a window from being draggable.


Olenn
09-28-2010, 12:21 PM
I have been digging through the wiki and I can not find anything that will allow you to prevent a window from being draggable.

Anyone got any ideas?

derk
09-28-2010, 01:43 PM
save the x and y position when the window is placed where you want it and then allow or disallow dragging in the PositionChanged event by setting the SetPosition to those saved x and y coords, self.movable is a flag you define yourself that you can set to allow positioning ( like in the constructor ), you can set that to false if you don't want it to be dragged anymore

function SomeClass:Constructor()

self.original_x = self:GetLeft();
self.original_y = self:GetTop();

self.PositionChanged = function ( sender, args )
if ( not self.movable ) then
self:SetPosition( self.original_x, self.original_y )
end
end
end

Olenn
09-29-2010, 09:34 AM
I have tried this code a million different ways and I can not figure out how to append it to my settings window to get it to lock and unlock the window when a check block is selected.


SetupWindow.lua

import "Turbine";
import "Turbine.Gameplay";
import "Turbine.UI";
import "Turbine.UI.Extensions";
import "Turbine.UI.Lotro";
import "Turbine.Utils";
import "Olenn.Satchel"
import "Olenn.DUInterface";
import "Olenn.Utilsx";

---Big thanks to Digital_Utopia for use of his code!

SetupWindow = class(Olenn.DUInterface.Window );

function SetupWindow:Constructor()
Olenn.DUInterface.Window.Constructor( self,380,225 );
----ENABLE LOCKING OF WINDOW----

----PREVENT MULTIPLE COPIES OF THIS WINDOW----
if ( self.window ~= nil ) then
return;
end
self:SetPosition((Turbine.UI.Display.GetWidth() / 2) - (self:GetWidth() / 2), (Turbine.UI.Display.GetHeight() / 2 ) - (self:GetHeight()));
self.tbHolder:SetWidth(255);
self.tbRight:SetPosition(self.tbHolder:GetWidth()-35,0)
self.tbHolder:SetLeft((self:GetWidth() - self.tbHolder:GetWidth())/2);
self.tbCenter:SetSize(self.tbHolder:GetWidth()-70,42);
self.tbCenter:SetPosition(self.tbLeft:GetLeft()+35 ,0)
self.bg:SetSize(325, 180);
self.text:SetText("Satchel Options");
self.text:SetWidth(self.tbHolder:GetWidth());
self.text:SetHeight(20);
self.text:SetLeft(-35);
self.text:SetTextAlignment(Turbine.UI.ContentAlign ment.MiddleCenter);
self.clButton:SetPosition(self:GetWidth()-23,24)
self.tw=Turbine.UI.Window();
self.tw:SetParent(self);
self.tw:SetSize(400,534);
self.tw:SetPosition(0,0);
self.tw:SetMouseVisible(false);


self.sp=Turbine.UI.ListBox();
self.sp:SetParent(self.tw);
self.sp:SetPosition(12,65);
self.sp:SetSize(356,448);


self.sp:SetOrientation( Turbine.UI.Orientation.Horizontal );
self.sp:SetMaxItemsPerLine(1);
self.sp:SetBackColorBlendMode(0);
self.sp:SetBlendMode(4);


----BOTTOM BUTTONS----
self.defSettings=Turbine.UI.Lotro.Button();
self.defSettings:SetParent(self.tw);
self.defSettings:SetSize(128,20);
self.defSettings:SetText("Default Settings");
self.defSettings:SetPosition(41, 190);

self.accSettings=Turbine.UI.Lotro.Button();
self.accSettings:SetParent(self.tw);
self.accSettings:SetSize(128,20);
self.accSettings:SetText("Accept");
self.accSettings:SetPosition(215,190);


----SATCHEL LOCKED CHECK BOX----
self.sp:AddItem(self.hdr);
self.sicHolder=Turbine.UI.Control();
self.sicHolder:SetSize(280,30);

self.locked = Olenn.DUInterface.CheckBox();
self.locked:SetChecked(true);
self.locked:SetText("Satchel locked");
self.locked:SetParent(self.sicHolder);
self.locked:SetPosition(-112,0);
self.sp:AddItem(self.sicHolder);


----SETTINGS SCOPE----
self.acHolder=Turbine.UI.Control();
self.acHolder:SetSize(400,30);

self.ac = Olenn.DUInterface.DropDownBox({"Account","Character","Server"});
self.ac:SetParent(self.acHolder);
self.ac:SetPosition(160,0);
self.acPanel = Turbine.UI.Window();
self.acPanel:SetParent(self.sp);
self.acPanel:SetPosition(0,0);
self.acPanel:SetSize(480,448);
self.acPanel:SetZOrder(99);
self.acPanel:SetVisible(false);
self.acLb = self.ac.listBox;
self.acLb:SetParent(self.acPanel);
self.acLb:SetZOrder(99);
self.acLb:SetBlendMode(0);
self.acLb:SetBackColorBlendMode(0);
self.acLb:SetPosition(200,200);
self.acLabel=Turbine.UI.Label();
self.acLabel:SetParent(self.acHolder);
self.acLabel:SetPosition(-34,0);
self.acLabel:SetSize(200,20);
self.acLabel:SetTextAlignment(Turbine.UI.ContentAl ignment.MiddleCenter);
self.acLabel:SetFont(Turbine.UI.Lotro.Font.TrajanP ro14);
self.acLabel:SetForeColor(Turbine.UI.Color(1,0.96, 0.874,0.576));
self.acLabel:SetText("Settings Scope");
self.sp:AddItem(self.acHolder);


----OPACITY SLIDER----
self.voHolder = Turbine.UI.Control();
self.voHolder:SetSize(335,45);

self.voSld = Olenn.DUInterface.Slider();
self.voSld:SetParent(self.voHolder);
self.voSld:SetLeft(20);
self.voSld:SetText("Opacity");
self.sp:AddItem(self.voHolder);

self.bpHolder = Turbine.UI.Control();
self.bpHolder:SetSize(335,45);



self.txHolder = Turbine.UI.Control();
self.txHolder:SetSize(400,45);


self.acPanel.MouseClick=function(sender,args)
self.ac.Close();
self.acPanel:SetVisible(false);
end


self.ac.Opening =function()
self.acPanel:SetVisible(true);
tl,tt=self.acHolder:PointToScreen(self.acHolder:Ge tPosition());
self.acLb:SetPosition(246,self.acHolder:GetTop()+2 1);

end


self.showSetup = function()

end

self.closeSetup = function()

end
end


SatchelWindow.lua

import "Turbine";
import "Turbine.Gameplay";
import "Turbine.UI";
import "Turbine.UI.Extensions";
import "Turbine.UI.Lotro";
import "Turbine.Utils";
import "Olenn.Satchel"

SatchelWindow = class( Turbine.UI.Window );

function SatchelWindow:Constructor()
----CREATE THE WINDOW----
Turbine.UI.Lotro.Window.Constructor( self );




self:SetText("Satchel");
self:SetSize( 325, 300 );
----LOAD PRIOR POSITION----
self.Data = Turbine.PluginData.Load( Turbine.DataScope.Character, "SatchelData")
if (self.Data==nil)then
self.Data = { };
self.Data.x = 100;
self.Data.y = 100;
self:SetPosition(100 , 100);
else
self:SetPosition(self.Data.x,self.Data.y)
end

----SATCHEL CLOSES WHEN ESC IS PRESSED----
self:SetWantsKeyEvents( true );
self.KeyDown = function( sender, args )
if ( args.Action == Turbine.UI.Lotro.Action.Escape ) then
sender:SetVisible( false )
end

----MAKE BAG BUTTONS ON THE TOOLBAR OPEN SATCHEL----
if ( args.Action == Turbine.UI.Lotro.Action.ToggleBags or
args.Action == Turbine.UI.Lotro.Action.ToggleBag1 or
args.Action == Turbine.UI.Lotro.Action.ToggleBag2 or
args.Action == Turbine.UI.Lotro.Action.ToggleBag3 or
args.Action == Turbine.UI.Lotro.Action.ToggleBag4 or
args.Action == Turbine.UI.Lotro.Action.ToggleBag5 )
then
sender:SetVisible( not sender:IsVisible() )
end
end

local satchel = self;
local mainWindow = self;

self.itemListBoxScrollBar = Turbine.UI.Lotro.ScrollBar();
self.itemListBoxScrollBar:SetOrientation( Turbine.UI.Orientation.Vertical );
self.itemListBoxScrollBar:SetParent( self );

self.itemListBox = Turbine.UI.ListBox();
self.itemListBox:SetParent( self );
self.itemListBox:SetOrientation( Turbine.UI.Orientation.Horizontal );
self.itemListBox:SetVerticalScrollBar( self.itemListBoxScrollBar );
self.itemListBox:SetAllowDrop( true );

self.itemListBox.DragDrop = function( sender, args )
local shortcut = args.DragDropInfo:GetShortcut();
if ( shortcut ~= nil ) then
local destinationItemControl = self.itemListBox:GetItemAt( args.X, args.Y );
local destinationIndex = self.itemListBox:IndexOfItem( destinationItemControl );
self.backpack:PerformShortcutDrop( shortcut, destinationIndex, Turbine.UI.Control.IsShiftKeyDown() );
end
end
----MAKE WINDOW RESIZABLE----
self.resizeHandle = Turbine.UI.Control();
self.resizeHandle:SetParent( self );
self.resizeHandle:SetZOrder( 100 );
self.resizeHandle:SetSize( 20, 20 );
self.resizeHandle:SetPosition( self:GetWidth() - self.resizeHandle:GetWidth(), self:GetHeight() - self.resizeHandle:GetHeight() );

self.resizeHandle.MouseDown = function( sender, args )
sender.dragStartX = args.X;
sender.dragStartY = args.Y;
sender.dragging = true;
end

self.resizeHandle.MouseMove = function( sender, args )
local width, height = mainWindow:GetSize();

if ( sender.dragging ) then
mainWindow:SetSize( width + ( args.X - sender.dragStartX ), height + ( args.Y - sender.dragStartY ) );
sender:SetPosition( mainWindow:GetWidth() - sender:GetWidth(), mainWindow:GetHeight() - sender:GetHeight() )
satchel:PerformLayout()
end
end

self.resizeHandle.MouseUp = function( sender, args )
if (sender.dragging) then
self.Data.x, self.Data.y = self:GetPosition();
end
sender.dragging = false;
end
----CREATE CONAINER FOR ITEMS----
self.items = { };

local player = Turbine.Gameplay.LocalPlayer();
self.backpack = player:GetBackpack();

self.backpack.SizeChanged = function( sender, args )
satchel:Refresh();
end

self.backpack.ItemAdded = function( sender, args )
satchel.items[args.Index]:SetItem( satchel.backpack:GetItem( args.Index ) );
end

self.backpack.ItemRemoved = function( sender, args )
satchel.items[args.Index]:SetItem( satchel.backpack:GetItem( args.Index ) );
end

self.backpack.ItemMoved = function( sender, args )
satchel.items[args.OldIndex]:SetItem( satchel.backpack:GetItem( args.OldIndex ) );
satchel.items[args.NewIndex]:SetItem( satchel.backpack:GetItem( args.NewIndex ) );
end

self:Refresh();

----CREATE SETTINGS BUTTON----
self.settingsButton = Turbine.UI.Lotro.Button();
self.settingsButton:SetParent( self );

self.settingsButton:SetSize(70,30);
self.settingsButton:SetPosition(34, 37);
self.settingsButton:SetFont(Turbine.UI.Lotro.Font. Verdana14);
self.settingsButton:SetText("Settings");
self.settingsButton.Click = function(sender, args)
SetupWindow:SetVisible( not SetupWindow:IsVisible() );
end

end

----FUNCTION TO REFRESH BAG CONTENTS----
function SatchelWindow:Refresh()
local backpackSize = self.backpack:GetSize();

for i = 1, backpackSize, 1 do
if ( self.items[i] ) then
self.items[i]:SetParent( nil );
end

self.items[i] = Turbine.UI.Lotro.ItemControl( self.backpack:GetItem( i ) );
self.itemListBox:AddItem( self.items[i] );
end

self:PerformLayout();
end

function SatchelWindow:PerformLayout()
self:Layout( { } )
end

function SatchelWindow:Layout( args )
local width, height = self:GetSize();

local itemWidth = 40;

if ( self.items[1] ~= nil ) then
itemWidth = self.items[1]:GetWidth()
end

local listWidth = width - 40;
local listHeight = height - 75;
local itemsPerRow = listWidth / itemWidth;

self.itemListBox:SetPosition( 15, 60 );
self.itemListBox:SetSize( listWidth, listHeight );
self.itemListBox:SetMaxItemsPerLine( itemsPerRow );

self.itemListBoxScrollBar:SetPosition( width - 25, 55 );
self.itemListBoxScrollBar:SetSize( 10, listHeight );

end




Any help is greatly appreciated. A lot of the time I can figure out and work through the code, but this is really stumping me.

Digital_Utopia
09-29-2010, 09:53 AM
This is a really dirty hack - but it's oh-so effective


myWindow = Turbine.UI.LotRO.Window()
---size/position code here
moveBlocker = Turbine.UI.Control()
moveBlocker:SetParent(myWindow);
moveBlocker:SetSize() -- size it so it's about the same size as the title bar
moveBlocker:SetPosition() -- position it above the title bar
moveBlocker:SetBackColor(Turbine.UI.Color(0,0,0)); -- keep temporarily to aid you in positioning
SetZOrder(10); -- just to make sure it's above everything else.


Now, you won't be able to drag it, or even get that 4-way cursor - because that control (moveBlocker) will intercept any mouse commands, and unlike the UI.Lotro window, a control won't auto-move on drag.

Olenn
09-29-2010, 02:38 PM
Nice, that's pretty smart...I will try it tonight!

Olenn
10-01-2010, 11:22 PM
Not sure why this isn't working... can you take a look at it when you get a sec?

The code in question is in the second block of code under ----LOCK WINDOW----



import "Turbine";
import "Turbine.Gameplay";
import "Turbine.UI";
import "Turbine.UI.Extensions";
import "Turbine.UI.Lotro";
import "Turbine.Utils";
import "Olenn.Satchel"
import "Olenn.DUInterface";
import "Olenn.Utilsx";

---Big thanks to Digital_Utopia for use of his code!

SetupWindow = class(Olenn.DUInterface.Window );

function SetupWindow:Constructor()
Olenn.DUInterface.Window.Constructor( self,380,225 );

----PREVENT MULTIPLE COPIES OF THIS WINDOW----
if ( self.window ~= nil ) then
return;
end
self:SetPosition((Turbine.UI.Display.GetWidth() / 2) - (self:GetWidth() / 2), (Turbine.UI.Display.GetHeight() / 2 ) - (self:GetHeight()));
self.tbHolder:SetWidth(255);
self.tbRight:SetPosition(self.tbHolder:GetWidth()-35,0)
self.tbHolder:SetLeft((self:GetWidth() - self.tbHolder:GetWidth())/2);
self.tbCenter:SetSize(self.tbHolder:GetWidth()-70,42);
self.tbCenter:SetPosition(self.tbLeft:GetLeft()+35 ,0)
self.bg:SetSize(325, 180);
self.text:SetText("Satchel Options");
self.text:SetWidth(self.tbHolder:GetWidth());
self.text:SetHeight(20);
self.text:SetLeft(-35);
self.text:SetTextAlignment(Turbine.UI.ContentAlign ment.MiddleCenter);
self.clButton:SetPosition(self:GetWidth()-23,24)
self.tw=Turbine.UI.Window();
self.tw:SetParent(self);
self.tw:SetSize(400,534);
self.tw:SetPosition(0,0);
self.tw:SetMouseVisible(false);


self.sp=Turbine.UI.ListBox();
self.sp:SetParent(self.tw);
self.sp:SetPosition(12,65);
self.sp:SetSize(356,448);


self.sp:SetOrientation( Turbine.UI.Orientation.Horizontal );
self.sp:SetMaxItemsPerLine(1);
self.sp:SetBackColorBlendMode(0);
self.sp:SetBlendMode(4);


----BOTTOM BUTTONS----
self.defSettings=Turbine.UI.Lotro.Button();
self.defSettings:SetParent(self.tw);
self.defSettings:SetSize(128,20);
self.defSettings:SetText("Default Settings");
self.defSettings:SetPosition(41, 190);

self.accSettings=Turbine.UI.Lotro.Button();
self.accSettings:SetParent(self.tw);
self.accSettings:SetSize(128,20);
self.accSettings:SetText("Accept");
self.accSettings:SetPosition(215,190);


----SATCHEL LOCKED CHECK BOX----
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);


----SETTINGS SCOPE----
self.acHolder=Turbine.UI.Control();
self.acHolder:SetSize(400,30);

self.ac = Olenn.DUInterface.DropDownBox({"Account","Character","Server"});
self.ac:SetParent(self.acHolder);
self.ac:SetPosition(160,0);
self.acPanel = Turbine.UI.Window();
self.acPanel:SetParent(self.sp);
self.acPanel:SetPosition(0,0);
self.acPanel:SetSize(480,448);
self.acPanel:SetZOrder(99);
self.acPanel:SetVisible(false);
self.acLb = self.ac.listBox;
self.acLb:SetParent(self.acPanel);
self.acLb:SetZOrder(99);
self.acLb:SetBlendMode(0);
self.acLb:SetBackColorBlendMode(0);
self.acLb:SetPosition(200,200);
self.acLabel=Turbine.UI.Label();
self.acLabel:SetParent(self.acHolder);
self.acLabel:SetPosition(-34,0);
self.acLabel:SetSize(200,20);
self.acLabel:SetTextAlignment(Turbine.UI.ContentAl ignment.MiddleCenter);
self.acLabel:SetFont(Turbine.UI.Lotro.Font.TrajanP ro14);
self.acLabel:SetForeColor(Turbine.UI.Color(1,0.96, 0.874,0.576));
self.acLabel:SetText("Settings Scope");
self.sp:AddItem(self.acHolder);


----OPACITY SLIDER----
self.voHolder = Turbine.UI.Control();
self.voHolder:SetSize(335,45);

self.voSld = Olenn.DUInterface.Slider();
self.voSld:SetParent(self.voHolder);
self.voSld:SetLeft(20);
self.voSld:SetText("Opacity");
self.sp:AddItem(self.voHolder);

self.bpHolder = Turbine.UI.Control();
self.bpHolder:SetSize(335,45);



self.txHolder = Turbine.UI.Control();
self.txHolder:SetSize(400,45);


self.acPanel.MouseClick=function(sender,args)
self.ac.Close();
self.acPanel:SetVisible(false);
end


self.ac.Opening =function()
self.acPanel:SetVisible(true);
tl,tt=self.acHolder:PointToScreen(self.acHolder:Ge tPosition());
self.acLb:SetPosition(246,self.acHolder:GetTop()+2 1);

end


self.showSetup = function()

end

self.closeSetup = function()

end
end



import "Turbine";
import "Turbine.Gameplay";
import "Turbine.UI";
import "Turbine.UI.Extensions";
import "Turbine.UI.Lotro";
import "Turbine.Utils";
import "Olenn.Satchel"

SatchelWindow = class( Turbine.UI.Window );
SetupWindow = Olenn.Satchel.SetupWindow();

function SatchelWindow:Constructor()
----CREATE THE WINDOW----
Turbine.UI.Lotro.Window.Constructor( self );
self:SetText("Satchel");
self:SetSize( 325, 300 );
----LOAD PRIOR SIZE & POSITION----
self.Data = Turbine.PluginData.Load( Turbine.DataScope.Character, "Satchel")
if (self.Data==nil)then
self.Data = { };
self.Data.x = Turbine.UI.Display.GetWidth() - 400;
self.Data.y = Turbine.UI.Display.GetHeight() - 300;
self.Data.sx = 325;
self.Data.sy = 300;
self:SetPosition(self.Data.x,self.Data.y);
self:GetSize(self.Data.sx,self.Data.sy);
else
self:SetPosition(self.Data.x,self.Data.y)
self:SetSize(self.Data.sx,self.Data.sy)
end

----SATCHEL SAVES SIZE & POSITION IF MOVED----
self.PositionChanged=function(sender,args)
self.Data.x,self.Data.y=self:GetPosition()
self.Data.sx,self.Data.sy=self:GetSize()
Turbine.PluginData.Save( Turbine.DataScope.Character, "Satchel", self.Data );
end

----SATCHEL CLOSES WHEN ESC IS PRESSED----
self:SetWantsKeyEvents( true );
self.KeyDown = function( sender, args )
if ( args.Action == Turbine.UI.Lotro.Action.Escape ) then
sender:SetVisible( false )
end

----MAKE BAG BUTTONS ON THE TOOLBAR OPEN SATCHEL----
if ( args.Action == Turbine.UI.Lotro.Action.ToggleBags or
args.Action == Turbine.UI.Lotro.Action.ToggleBag1 or
args.Action == Turbine.UI.Lotro.Action.ToggleBag2 or
args.Action == Turbine.UI.Lotro.Action.ToggleBag3 or
args.Action == Turbine.UI.Lotro.Action.ToggleBag4 or
args.Action == Turbine.UI.Lotro.Action.ToggleBag5 )
then
sender:SetVisible( not sender:IsVisible() )
end
end

local satchel = self;
local mainWindow = self;

self.itemListBoxScrollBar = Turbine.UI.Lotro.ScrollBar();
self.itemListBoxScrollBar:SetOrientation( Turbine.UI.Orientation.Vertical );
self.itemListBoxScrollBar:SetParent( self );

self.itemListBox = Turbine.UI.ListBox();
self.itemListBox:SetParent( self );
self.itemListBox:SetOrientation( Turbine.UI.Orientation.Horizontal );
self.itemListBox:SetVerticalScrollBar( self.itemListBoxScrollBar );
self.itemListBox:SetAllowDrop( true );

self.itemListBox.DragDrop = function( sender, args )
local shortcut = args.DragDropInfo:GetShortcut();
if ( shortcut ~= nil ) then
local destinationItemControl = self.itemListBox:GetItemAt( args.X, args.Y );
local destinationIndex = self.itemListBox:IndexOfItem( destinationItemControl );
self.backpack:PerformShortcutDrop( shortcut, destinationIndex, Turbine.UI.Control.IsShiftKeyDown() );
end
end
----MAKE WINDOW RESIZABLE----
self.resizeHandle = Turbine.UI.Control();
self.resizeHandle:SetParent( self );
self.resizeHandle:SetZOrder( 100 );
self.resizeHandle:SetSize( 20, 20 );
self.resizeHandle:SetPosition( self:GetWidth() - self.resizeHandle:GetWidth(), self:GetHeight() - self.resizeHandle:GetHeight() );

self.resizeHandle.MouseDown = function( sender, args )
sender.dragStartX = args.X;
sender.dragStartY = args.Y;
sender.dragging = true;
end

self.resizeHandle.MouseMove = function( sender, args )
local width, height = mainWindow:GetSize();

if ( sender.dragging ) then
mainWindow:SetSize( width + ( args.X - sender.dragStartX ), height + ( args.Y - sender.dragStartY ) );
sender:SetPosition( mainWindow:GetWidth() - sender:GetWidth(), mainWindow:GetHeight() - sender:GetHeight() )
satchel:PerformLayout()
end
end

self.resizeHandle.MouseUp = function( sender, args )
if (sender.dragging) then
self.Data.x, self.Data.y = self:GetPosition();
end
sender.dragging = false;
end
----CREATE CONAINER FOR ITEMS----
self.items = { };

local player = Turbine.Gameplay.LocalPlayer();
self.backpack = player:GetBackpack();

self.backpack.SizeChanged = function( sender, args )
satchel:Refresh();
end

self.backpack.ItemAdded = function( sender, args )
satchel.items[args.Index]:SetItem( satchel.backpack:GetItem( args.Index ) );
end

self.backpack.ItemRemoved = function( sender, args )
satchel.items[args.Index]:SetItem( satchel.backpack:GetItem( args.Index ) );
end

self.backpack.ItemMoved = function( sender, args )
satchel.items[args.OldIndex]:SetItem( satchel.backpack:GetItem( args.OldIndex ) );
satchel.items[args.NewIndex]:SetItem( satchel.backpack:GetItem( args.NewIndex ) );
end

self:Refresh();

----CREATE SETTINGS BUTTON----
self.settingsButton = Turbine.UI.Lotro.Button();
self.settingsButton:SetParent( self );

self.settingsButton:SetSize(70,30);
self.settingsButton:SetPosition(34, 37);
self.settingsButton:SetFont(Turbine.UI.Lotro.Font. Verdana14);
self.settingsButton:SetText("Settings");
self.settingsButton.Click = function(sender, args)
SetupWindow:SetVisible( not SetupWindow:IsVisible() );
end

----LOCK WINDOW----
if ( SetupWindow.locked:IsChecked(true) ) then
moveBlocker = Turbine.UI.Control()
moveBlocker:SetParent(self);
moveBlocker:SetSize(329,40) -- size it so it's about the same size as the title bar
moveBlocker:SetPosition(-10,0) -- position it above the title bar
end


end

----FUNCTION TO REFRESH BAG CONTENTS----
function SatchelWindow:Refresh()
local backpackSize = self.backpack:GetSize();

for i = 1, backpackSize, 1 do
if ( self.items[i] ) then
self.items[i]:SetParent( nil );
end

self.items[i] = Turbine.UI.Lotro.ItemControl( self.backpack:GetItem( i ) );
self.itemListBox:AddItem( self.items[i] );
end

self:PerformLayout();
end

function SatchelWindow:PerformLayout()
self:Layout( { } )
end

function SatchelWindow:Layout( args )
local width, height = self:GetSize();

local itemWidth = 40;

if ( self.items[1] ~= nil ) then
itemWidth = self.items[1]:GetWidth()
end

local listWidth = width - 40;
local listHeight = height - 75;
local itemsPerRow = listWidth / itemWidth;

self.itemListBox:SetPosition( 15, 60 );
self.itemListBox:SetSize( listWidth, listHeight );
self.itemListBox:SetMaxItemsPerLine( itemsPerRow );

self.itemListBoxScrollBar:SetPosition( width - 25, 55 );
self.itemListBoxScrollBar:SetSize( 10, listHeight );

end

Digital_Utopia
10-02-2010, 12:35 AM
No...no.

See, you add that window/control to the window when you make the window itself, starting off with a background color so you can place and size it correctly. Once you do that, the only thing you have to put in your conditional is switching mouse visible on and off. eg:


SetupWindow = class(Olenn.DUInterface.Window );

function SetupWindow:Constructor()
Olenn.DUInterface.Window.Constructor( self,380,225 );

self.moveBlocker=Turbine.UI.Window();
self.moveBlocker:SetParent(self);
--Width should be about 25px less than self's width
self.moveBlocker:SetSize(355,35);
self.moveBlocker:SetPosition(0,0);
-- remove following line after you make sure it's placed correctly
self.moveBlocker:SetBackColor(Turbine.UI.Color(0,0 ,0));
self.moveBlocker:SetZOrder(20);
--next line will make it so window can be moved by default
--omit it if you want the opposite (SetMouseVisible defaults to true)
self.moveBlocker:SetMouseVisible(false);


Then your initial conditional


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


finally an event handler example:


SetupWindow.locked.CheckChanged = function (sender,args)
self.moveBlocker:SetMouseVisible(SetupWindow.locke d:IsChecked());
end

Olenn
10-02-2010, 01:45 AM
I think there is a basic key understanding of Lua that I am missing. Here is the error;


...Rings Online\Plugins\Olenn\Satchel\SatchelWindow.lua:206 : attempt to index field 'locked' (a nil value)
... the Rings Online\Plugins\Olenn\Satchel/__init__.lua:1: Failed to import package "Olenn.Satchel.SatchelWindow".
...d of the Rings Online\Plugins\Olenn\Satchel\Main.lua:4: Failed to import package "Olenn.Satchel".


What am I forgeting to do? I don't understand why main failed to import Olenn.Satchel. I didn't even touch main.lua. There must be something easy that I am missing.

Here is all of the code thus far.

SatchelWindow.lua

import "Turbine";
import "Turbine.Gameplay";
import "Turbine.UI";
import "Turbine.UI.Extensions";
import "Turbine.UI.Lotro";
import "Turbine.Utils";
import "Olenn.Satchel"
import "Olenn.DUInterface";

SatchelWindow = class( Turbine.UI.Window );

SetupWindow = class(Olenn.DUInterface.Window );


function SatchelWindow:Constructor()
----CREATE THE WINDOW----
Turbine.UI.Lotro.Window.Constructor( self );
self:SetText("Satchel");


----LOAD PRIOR SIZE & POSITION----
self.Data = Turbine.PluginData.Load( Turbine.DataScope.Character, "Satchel")
if (self.Data==nil)then
self.Data = { };
self.Data.x = Turbine.UI.Display.GetWidth() - 400;
self.Data.y = Turbine.UI.Display.GetHeight() - 300;
self.Data.sx = 325;
self.Data.sy = 300;
self:SetPosition(self.Data.x,self.Data.y);
self:GetSize(self.Data.sx,self.Data.sy);
else
self:SetPosition(self.Data.x,self.Data.y)
self:SetSize(self.Data.sx,self.Data.sy)
end

----SATCHEL SAVES SIZE & POSITION IF MOVED----
self.PositionChanged=function(sender,args)
self.Data.x,self.Data.y=self:GetPosition()
self.Data.sx,self.Data.sy=self:GetSize()
Turbine.PluginData.Save( Turbine.DataScope.Character, "Satchel", self.Data );
end

----Lock Window----
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);


----SATCHEL CLOSES WHEN ESC IS PRESSED----
self:SetWantsKeyEvents( true );
self.KeyDown = function( sender, args )
if ( args.Action == Turbine.UI.Lotro.Action.Escape ) then
sender:SetVisible( false )
end

----MAKE BAG BUTTONS ON THE TOOLBAR OPEN SATCHEL----
if ( args.Action == Turbine.UI.Lotro.Action.ToggleBags or
args.Action == Turbine.UI.Lotro.Action.ToggleBag1 or
args.Action == Turbine.UI.Lotro.Action.ToggleBag2 or
args.Action == Turbine.UI.Lotro.Action.ToggleBag3 or
args.Action == Turbine.UI.Lotro.Action.ToggleBag4 or
args.Action == Turbine.UI.Lotro.Action.ToggleBag5 )
then
sender:SetVisible( not sender:IsVisible() )
end
end

local satchel = self;
local mainWindow = self;

self.itemListBoxScrollBar = Turbine.UI.Lotro.ScrollBar();
self.itemListBoxScrollBar:SetOrientation( Turbine.UI.Orientation.Vertical );
self.itemListBoxScrollBar:SetParent( self );

self.itemListBox = Turbine.UI.ListBox();
self.itemListBox:SetParent( self );
self.itemListBox:SetOrientation( Turbine.UI.Orientation.Horizontal );
self.itemListBox:SetVerticalScrollBar( self.itemListBoxScrollBar );
self.itemListBox:SetAllowDrop( true );

self.itemListBox.DragDrop = function( sender, args )
local shortcut = args.DragDropInfo:GetShortcut();
if ( shortcut ~= nil ) then
local destinationItemControl = self.itemListBox:GetItemAt( args.X, args.Y );
local destinationIndex = self.itemListBox:IndexOfItem( destinationItemControl );
self.backpack:PerformShortcutDrop( shortcut, destinationIndex, Turbine.UI.Control.IsShiftKeyDown() );
end
end
----MAKE WINDOW RESIZABLE----
self.resizeHandle = Turbine.UI.Control();
self.resizeHandle:SetParent( self );
self.resizeHandle:SetZOrder( 100 );
self.resizeHandle:SetSize( 20, 20 );
self.resizeHandle:SetPosition( self:GetWidth() - self.resizeHandle:GetWidth(), self:GetHeight() - self.resizeHandle:GetHeight() );

self.resizeHandle.MouseDown = function( sender, args )
sender.dragStartX = args.X;
sender.dragStartY = args.Y;
sender.dragging = true;
end

self.resizeHandle.MouseMove = function( sender, args )
local width, height = mainWindow:GetSize();

if ( sender.dragging ) then
mainWindow:SetSize( width + ( args.X - sender.dragStartX ), height + ( args.Y - sender.dragStartY ) );
sender:SetPosition( mainWindow:GetWidth() - sender:GetWidth(), mainWindow:GetHeight() - sender:GetHeight() )
satchel:PerformLayout()
end
end

self.resizeHandle.MouseUp = function( sender, args )
if (sender.dragging) then
self.Data.x, self.Data.y = self:GetPosition();
end
sender.dragging = false;
end
----CREATE CONAINER FOR ITEMS----
self.items = { };

local player = Turbine.Gameplay.LocalPlayer();
self.backpack = player:GetBackpack();

self.backpack.SizeChanged = function( sender, args )
satchel:Refresh();
end

self.backpack.ItemAdded = function( sender, args )
satchel.items[args.Index]:SetItem( satchel.backpack:GetItem( args.Index ) );
end

self.backpack.ItemRemoved = function( sender, args )
satchel.items[args.Index]:SetItem( satchel.backpack:GetItem( args.Index ) );
end

self.backpack.ItemMoved = function( sender, args )
satchel.items[args.OldIndex]:SetItem( satchel.backpack:GetItem( args.OldIndex ) );
satchel.items[args.NewIndex]:SetItem( satchel.backpack:GetItem( args.NewIndex ) );
end

self:Refresh();

----CREATE SETTINGS BUTTON----
self.settingsButton = Turbine.UI.Lotro.Button();
self.settingsButton:SetParent( self );

self.settingsButton:SetSize(70,30);
self.settingsButton:SetPosition(34, 37);
self.settingsButton:SetFont(Turbine.UI.Lotro.Font. Verdana14);
self.settingsButton:SetText("Settings");
self.settingsButton.Click = function(sender, args)
SetupWindow:SetVisible( not SetupWindow:IsVisible() );
end





end

----FUNCTION TO REFRESH BAG CONTENTS----
function SatchelWindow:Refresh()
local backpackSize = self.backpack:GetSize();

for i = 1, backpackSize, 1 do
if ( self.items[i] ) then
self.items[i]:SetParent( nil );
end

self.items[i] = Turbine.UI.Lotro.ItemControl( self.backpack:GetItem( i ) );
self.itemListBox:AddItem( self.items[i] );
end

self:PerformLayout();
end

function SatchelWindow:PerformLayout()
self:Layout( { } )
end

function SatchelWindow:Layout( args )
local width, height = self:GetSize();

local itemWidth = 40;

if ( self.items[1] ~= nil ) then
itemWidth = self.items[1]:GetWidth()
end

local listWidth = width - 40;
local listHeight = height - 75;
local itemsPerRow = listWidth / itemWidth;

self.itemListBox:SetPosition( 15, 60 );
self.itemListBox:SetSize( listWidth, listHeight );
self.itemListBox:SetMaxItemsPerLine( itemsPerRow );

self.itemListBoxScrollBar:SetPosition( width - 25, 55 );
self.itemListBoxScrollBar:SetSize( 10, listHeight );

end

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

SetupWindow.locked.CheckChanged = function (sender,args)
self.moveBlocker:SetMouseVisible(SetupWindow.locke d:IsChecked());
end


SetupWindow.lua

import "Turbine";
import "Turbine.Gameplay";
import "Turbine.UI";
import "Turbine.UI.Extensions";
import "Turbine.UI.Lotro";
import "Turbine.Utils";
import "Olenn.Satchel"
import "Olenn.DUInterface";
import "Olenn.Utilsx";

---Big thanks to Digital_Utopia for use of his code!

SetupWindow = class(Olenn.DUInterface.Window );

function SetupWindow:Constructor()
Olenn.DUInterface.Window.Constructor( self,380,225 );

----PREVENT MULTIPLE COPIES OF THIS WINDOW----
if ( self.window ~= nil ) then
return;
end
self:SetPosition((Turbine.UI.Display.GetWidth() / 2) - (self:GetWidth() / 2), (Turbine.UI.Display.GetHeight() / 2 ) - (self:GetHeight()));
self.tbHolder:SetWidth(255);
self.tbRight:SetPosition(self.tbHolder:GetWidth()-35,0)
self.tbHolder:SetLeft((self:GetWidth() - self.tbHolder:GetWidth())/2);
self.tbCenter:SetSize(self.tbHolder:GetWidth()-70,42);
self.tbCenter:SetPosition(self.tbLeft:GetLeft()+35 ,0)
self.bg:SetSize(325, 180);
self.text:SetText("Satchel Options");
self.text:SetWidth(self.tbHolder:GetWidth());
self.text:SetHeight(20);
self.text:SetLeft(-35);
self.text:SetTextAlignment(Turbine.UI.ContentAlign ment.MiddleCenter);
self.clButton:SetPosition(self:GetWidth()-23,24)
self.tw=Turbine.UI.Window();
self.tw:SetParent(self);
self.tw:SetSize(400,534);
self.tw:SetPosition(0,0);
self.tw:SetMouseVisible(false);


self.sp=Turbine.UI.ListBox();
self.sp:SetParent(self.tw);
self.sp:SetPosition(12,65);
self.sp:SetSize(356,448);


self.sp:SetOrientation( Turbine.UI.Orientation.Horizontal );
self.sp:SetMaxItemsPerLine(1);
self.sp:SetBackColorBlendMode(0);
self.sp:SetBlendMode(4);


----BOTTOM BUTTONS----
self.defSettings=Turbine.UI.Lotro.Button();
self.defSettings:SetParent(self.tw);
self.defSettings:SetSize(128,20);
self.defSettings:SetText("Default Settings");
self.defSettings:SetPosition(41, 190);

self.accSettings=Turbine.UI.Lotro.Button();
self.accSettings:SetParent(self.tw);
self.accSettings:SetSize(128,20);
self.accSettings:SetText("Accept");
self.accSettings:SetPosition(215,190);


----SATCHEL LOCKED CHECK BOX----
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);




----SETTINGS SCOPE----
self.acHolder=Turbine.UI.Control();
self.acHolder:SetSize(400,30);

self.ac = Olenn.DUInterface.DropDownBox({"Account","Character","Server"});
self.ac:SetParent(self.acHolder);
self.ac:SetPosition(160,0);
self.acPanel = Turbine.UI.Window();
self.acPanel:SetParent(self.sp);
self.acPanel:SetPosition(0,0);
self.acPanel:SetSize(480,448);
self.acPanel:SetZOrder(99);
self.acPanel:SetVisible(false);
self.acLb = self.ac.listBox;
self.acLb:SetParent(self.acPanel);
self.acLb:SetZOrder(99);
self.acLb:SetBlendMode(0);
self.acLb:SetBackColorBlendMode(0);
self.acLb:SetPosition(200,200);
self.acLabel=Turbine.UI.Label();
self.acLabel:SetParent(self.acHolder);
self.acLabel:SetPosition(-34,0);
self.acLabel:SetSize(200,20);
self.acLabel:SetTextAlignment(Turbine.UI.ContentAl ignment.MiddleCenter);
self.acLabel:SetFont(Turbine.UI.Lotro.Font.TrajanP ro14);
self.acLabel:SetForeColor(Turbine.UI.Color(1,0.96, 0.874,0.576));
self.acLabel:SetText("Settings Scope");
self.sp:AddItem(self.acHolder);


----OPACITY SLIDER----
self.voHolder = Turbine.UI.Control();
self.voHolder:SetSize(335,45);

self.voSld = Olenn.DUInterface.Slider();
self.voSld:SetParent(self.voHolder);
self.voSld:SetLeft(20);
self.voSld:SetText("Opacity");
self.sp:AddItem(self.voHolder);

self.bpHolder = Turbine.UI.Control();
self.bpHolder:SetSize(335,45);



self.txHolder = Turbine.UI.Control();
self.txHolder:SetSize(400,45);


self.acPanel.MouseClick=function(sender,args)
self.ac.Close();
self.acPanel:SetVisible(false);
end


self.ac.Opening =function()
self.acPanel:SetVisible(true);
tl,tt=self.acHolder:PointToScreen(self.acHolder:Ge tPosition());
self.acLb:SetPosition(246,self.acHolder:GetTop()+2 1);

end


self.showSetup = function()

end

self.closeSetup = function()

end
end


And thanks for the help once again DU.

Kragenwar
10-02-2010, 02:50 AM
In SatchelWindow.lua this part

import "Turbine";
import "Turbine.Gameplay";
import "Turbine.UI";
import "Turbine.UI.Extensions";
import "Turbine.UI.Lotro";
import "Turbine.Utils";
import "Olenn.Satchel"
import "Olenn.DUInterface";

SatchelWindow = class( Turbine.UI.Window );

SetupWindow = class(Olenn.DUInterface.Window );


I don't know why you changed it. Before you changed it, the very last line there was creating an instance of the class setupWindow. Now you have it defining SetupWindow as a class (which is already rightfully done in the setupwindow.lua file). It should probably read as.


import "Turbine";
import "Turbine.Gameplay";
import "Turbine.UI";
import "Turbine.UI.Extensions";
import "Turbine.UI.Lotro";
import "Turbine.Utils";
import "Olenn.Satchel"
import "Olenn.DUInterface";

SatchelWindow = class( Turbine.UI.Window );

SetupWindow = Olenn.Satchel.SetupWindow();



As for your error about main, basically its telling you it can't load SatchelWindow.lua because of the above problem (SetupWindow.locked doesnt exsist because you didnt create an instance of the class setupWindow). Since it can't load that file init.lua cant import the Olen.SatchWindow package. Which also means that Main.lua cant import the Olen.Satchel package. Usually when you get a string of errors like that, you wanna just focus on the first one listed. Because quite often the unable to import errors are caused by that.

Digital_Utopia
10-02-2010, 04:04 AM
I think there is a basic key understanding of Lua that I am missing. Here is the error;



And thanks for the help once again DU.

First of all, I think you're not quite understanding classes in Lua.

SetupWindow and SatchelWindow are classes, and as such do nothing unless an instance is made of them. eg:


--in Main.lua

setup=SetupWindow();
satchel = SatchelWindow();



Now, you can do whatever you want to each instance of the class in Main.lua, but you can't do anything to the SetupWindow class in SatchelWindow, nor vice versa. Classes are essentially blueprints, containing code that describes their appearance and behavior. Just like you can't walk into a blueprint of a house and sit down and watch TV, you can't do anything with a Class, unless you actually build yourself a copy of it by declaring an instance.

Ever see one of those suburban neighborhoods where it's obvious that all the houses were built off the same blueprints, and the only thing really different about them is the changes the owners made to them (i.e. paint color)? If that were a program, each house would be an instance of the same class. eg:


myhouse = House();
yourhouse = House();
bobshouse = House();
crazyguyshouse = House();
...


Now from there, you could change any instance - using any function/property available to you in that class, or any class House inherits. eg:


myhouse:Paint(red);
yourhouse:Paint(blue);


You could even add a pool if you wanted


myPool = Pool();


Now let's say you wanted to oh...I dunno, put in a pool light in your pool. Now that could be done quite easily here, by doing something like:


myPool:AddLight()


However, if you tried to do this in the House class itself...


House = class( Entertainment.Outside );

function House:Constructor()
Entertainment.Outside.Constructor( self );

function self:Paint(color)
--code here paints the house at the specified color
end

--wait, what?

if (Pool.isAboveGround() == true)then
self.Paint(blue)
else
self.Paint(yellow)
end

end


Well, that would get a big error - a House has nothing to do with a Pool, and even if it knew exactly what a Pool was (i.e. by importing the class), it wouldn't know which pool to check to see if it was AboveGround or not.

On the other hand, doing something like this, in the same class/file as you created instances of houses would work


if (myPool:isAboveGround()==true)then
myHouse:Paint(blue)
else
myHouse:Paint(yellow)
end



Now, if you somehow really needed to make sure every house was painted blue or yellow based on whether the pool was above ground or not, then..you could just create an instance within House(), and that way every house would come with a pool eg:



House = class( Entertainment.Outside );

function House:Constructor()
Entertainment.Outside.Constructor( self );

function self:Paint(color)
--code here paints the house at the specified color
end

--A pool for every house!

self.zePool=Pool();

if (self.zePool.isAboveGround() == true)then
self.Paint(blue)
else
self.Paint(yellow)
end

end


See if you notice, we're still not checking for the class itself (i.e. Pool) but rather an instance we created inside that class. But unlike before, we can now decide how to make a House based on what the properties of its pool are. It's important to note that either the House class, or the Pool class would need to have a constructor that sets whether the pool is above ground or not, otherwise the answer will always be what the default value of that property is.

Now that we have a declaration of Pool inside House, we can still access it from outside of House as well eg:


myHouse.zePool:AddLight();


While this doesn't specifically fix your code, I hope it was informative enough for you to get a better understanding how classes work, and how to use them - not only inside Lua, but in other languages as well. If you can now see where your problem is, then I've accomplished my goal. If you have any questions, please feel free to ask!

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



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



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;


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
Wow, thanks DU, that should be stickied.

I guess that my problem is this;

When I add this to SetupWindow.lua



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



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;


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

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;


61 SetupWindow.locked.CheckChanged=function(sender,ar gs)
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