Quantcast Prevent a window from being draggable. - LoTROInterface
VGInterface.com
Search Downloads


Go Back   LoTROInterface > LotRO > Developer Discussions > Lua Programming Help (L)

Reply
Thread Tools Display Modes
  #1  
Unread 09-28-2010, 12:21 PM
Olenn's Avatar
Olenn Olenn is offline
The Undying
Interface Author - Click to view interfaces
 
Join Date: Sep 2010
Posts: 47
Prevent a window from being draggable.

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?
Reply With Quote
  #2  
Unread 09-28-2010, 01:43 PM
derk derk is offline
The Wary
 
Join Date: Sep 2010
Posts: 3
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

Code:
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
Reply With Quote
  #3  
Unread 09-29-2010, 09:34 AM
Olenn's Avatar
Olenn Olenn is offline
The Undying
Interface Author - Click to view interfaces
 
Join Date: Sep 2010
Posts: 47
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
Code:
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.ContentAlignment.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.ContentAlignment.MiddleCenter);
	self.acLabel:SetFont(Turbine.UI.Lotro.Font.TrajanPro14);
	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:GetPosition());
		self.acLb:SetPosition(246,self.acHolder:GetTop()+21);
		
	end
	

	self.showSetup = function()
		
	end
	
	self.closeSetup = function()
	
	end
end
SatchelWindow.lua
Code:
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.
Reply With Quote
  #4  
Unread 09-29-2010, 09:53 AM
Digital_Utopia's Avatar
Digital_Utopia Digital_Utopia is offline
The Undying
Interface Author - Click to view interfaces
 
Join Date: Sep 2010
Posts: 207
Send a message via MSN to Digital_Utopia Send a message via Yahoo to Digital_Utopia
This is a really dirty hack - but it's oh-so effective

Code:
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.
__________________

Lord of the Rings Online
75 Fourohfour | 75 Artemedis | 60 Whiskeytango Foxtrot | 50 Mistah Boombastic | 56 Appetizer | 25 Aggromi
61 Onepointtwentyone Gigawatts


World of Warcraft
90 Downlo 85 Gravetaxi 85 Ümad 85 Artemedis 85 Guthuros
Reply With Quote
  #5  
Unread 09-29-2010, 02:38 PM
Olenn's Avatar
Olenn Olenn is offline
The Undying
Interface Author - Click to view interfaces
 
Join Date: Sep 2010
Posts: 47
Nice, that's pretty smart...I will try it tonight!

Last edited by Olenn : 09-29-2010 at 07:23 PM.
Reply With Quote
  #6  
Unread 10-01-2010, 11:22 PM
Olenn's Avatar
Olenn Olenn is offline
The Undying
Interface Author - Click to view interfaces
 
Join Date: Sep 2010
Posts: 47
@DU

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----


Code:
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.ContentAlignment.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.ContentAlignment.MiddleCenter);
	self.acLabel:SetFont(Turbine.UI.Lotro.Font.TrajanPro14);
	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:GetPosition());
		self.acLb:SetPosition(246,self.acHolder:GetTop()+21);
		
	end
	

	self.showSetup = function()
		
	end
	
	self.closeSetup = function()
	
	end
end
Code:
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
Reply With Quote
  #7  
Unread 10-02-2010, 12:35 AM
Digital_Utopia's Avatar
Digital_Utopia Digital_Utopia is offline
The Undying
Interface Author - Click to view interfaces
 
Join Date: Sep 2010
Posts: 207
Send a message via MSN to Digital_Utopia Send a message via Yahoo to Digital_Utopia
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:

Code:
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

Code:
if ( SetupWindow.locked:IsChecked(true) ) then
     self.moveBlocker:SetMouseVisible(true);
else
     self.moveBlocker:SetMouseVisible(false);
end
finally an event handler example:

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

Lord of the Rings Online
75 Fourohfour | 75 Artemedis | 60 Whiskeytango Foxtrot | 50 Mistah Boombastic | 56 Appetizer | 25 Aggromi
61 Onepointtwentyone Gigawatts


World of Warcraft
90 Downlo 85 Gravetaxi 85 Ümad 85 Artemedis 85 Guthuros
Reply With Quote
  #8  
Unread 10-02-2010, 01:45 AM
Olenn's Avatar
Olenn Olenn is offline
The Undying
Interface Author - Click to view interfaces
 
Join Date: Sep 2010
Posts: 47
I think there is a basic key understanding of Lua that I am missing. Here is the error;

Code:
...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
Code:
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.locked:IsChecked());
	end
SetupWindow.lua
Code:
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.ContentAlignment.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.ContentAlignment.MiddleCenter);
	self.acLabel:SetFont(Turbine.UI.Lotro.Font.TrajanPro14);
	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:GetPosition());
		self.acLb:SetPosition(246,self.acHolder:GetTop()+21);
		
	end
	

	self.showSetup = function()
		
	end
	
	self.closeSetup = function()
	
	end
end
And thanks for the help once again DU.
Reply With Quote
  #9  
Unread 10-02-2010, 02:50 AM
Kragenwar Kragenwar is offline
The Undying
Interface Author - Click to view interfaces
 
Join Date: Sep 2010
Posts: 26
In SatchelWindow.lua this part
Code:
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.

Code:
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.

Last edited by Kragenwar : 10-02-2010 at 05:31 AM.
Reply With Quote
  #10  
Unread 10-02-2010, 04:04 AM
Digital_Utopia's Avatar
Digital_Utopia Digital_Utopia is offline
The Undying
Interface Author - Click to view interfaces
 
Join Date: Sep 2010
Posts: 207
Send a message via MSN to Digital_Utopia Send a message via Yahoo to Digital_Utopia
Quote:
Originally Posted by Olenn
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:

Code:
--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:

Code:
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:

Code:
myhouse:Paint(red);
yourhouse:Paint(blue);
You could even add a pool if you wanted

Code:
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:

Code:
myPool:AddLight()
However, if you tried to do this in the House class itself...

Code:
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

Code:
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:


Code:
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:

Code:
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!
__________________

Lord of the Rings Online
75 Fourohfour | 75 Artemedis | 60 Whiskeytango Foxtrot | 50 Mistah Boombastic | 56 Appetizer | 25 Aggromi
61 Onepointtwentyone Gigawatts


World of Warcraft
90 Downlo 85 Gravetaxi 85 Ümad 85 Artemedis 85 Guthuros
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Saving window position Olenn Lua Programming Help (L) 25 10-01-2010 01:08 AM
Quest Window Normandy9 Interface Requests (L) 0 09-12-2010 05:38 PM
Raid window? Kyosen Graphics modification help (L) 4 06-13-2008 07:58 PM
Horizontal Fellowship window? Askyn Interface Help (L) 4 01-01-2008 04:45 PM
Is there an implied target window? zelindar Interface Help (L) 1 06-15-2007 05:04 PM


All times are GMT -5. The time now is 07:27 PM.


Our Network
EQInterface | EQ2Interface | Minion | WoWInterface | VGInterface | LoTROInterface | MMOInterface | Swtorui