lotrointerface.com
Search Downloads


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

Reply
Thread Tools Display Modes
  #1  
Unread 12-08-2010, 06:19 PM
Marll's Avatar
Marll Marll is offline
The Undying
Interface Author - Click to view interfaces
 
Join Date: Jan 2010
Posts: 51
Saving quickslot data to table

A little background: I looked at Paulino's code for the Pet Carousel and modified it to make a mount carousel. It was a quick and dirty conversion, and I've never been happy with it fully, since you have to edit the code each time you want to add a mount.

I've been making a few modifications, like being able to scroll forward and backward in the carousel, setting the center slot in the carousel to allow drops, but the thing that just eludes me is the ability to save the data of what is dropped into the carousel and read it back so that people could use it without having to modify code.

I just CANNOT seem to wrap my head around the concept and how to write it into my plugin. I've been looking at examples from Travel Window and Wheel, which do similar things to what I want, but as is normal each author writes up the code differently, and even coupled with Lua examples I can find, I'm a bit lost.

I'm a dolt when it comes to code, I've done programming before, but generally do not enjoy it much, this however I find more fun, (probably because it's a game that enjoy playing) but still frustrating.

Any suggestions, code samples or pointing me to other resources is much appreciated.
Reply With Quote
  #2  
Unread 12-09-2010, 01:33 AM
MrJackdaw's Avatar
MrJackdaw MrJackdaw is offline
The Undying
Interface Author - Click to view interfaces
 
Join Date: Feb 2009
Location: Lancaster, England
Posts: 249
Code:
--Returns a table of the shortcuts in the quickslots.
function StoreSlots(self)
		destination={}
		for i = 1,#self do
			local shortcut=self[i]:GetShortcut()
			destination[i]={}
			destination[i].Data=shortcut:GetData()
			destination[i].Type=shortcut:GetType()
		end
		return destination
end

--Load shortcuts from the source table.
function LoadSlots(self,source)
	for i=1,#self do
	if source~=nil then PSetShortcut(self[i],Turbine.UI.Lotro.Shortcut( source[i].Type,source[i].Data )) end
	end
end
This (1) loads the shortcuts from a table of quickslots. (2) sets the shortcuts in a table of quickslots!

To use, lets say you had a table of quickslots called Geoff and wanted to store the shortcuts in a table called GeoffStore;

Code:
GeoffStore=StoreSlots(Geoff)
To load again;

Code:
LoadSlots(Geoff,GeoffStore)
NB: This is a slightly modified version of what is in the library for bevyobars - have a look if you like. This may not be the most elegant way of doing it, but it works for me! Also, as it is modified I ain't tested it...
__________________
************************************************** ************************************************** **
"Our ideals may never be realised, But they indicate what we are trying to do." Dick Tahta
Reply With Quote
  #3  
Unread 12-09-2010, 07:32 PM
Marll's Avatar
Marll Marll is offline
The Undying
Interface Author - Click to view interfaces
 
Join Date: Jan 2010
Posts: 51
Thanks, I'll give this a shot. Trying to re-write the plugin now, but probably won't have time to test it until this weekend. I'm also trying to break the code up into several Lua files to make it easier to read, so we'll see how that goes
Reply With Quote
  #4  
Unread 12-20-2010, 02:40 PM
Marll's Avatar
Marll Marll is offline
The Undying
Interface Author - Click to view interfaces
 
Join Date: Jan 2010
Posts: 51
So, another question. If I set a quickslot to allow drops, I drop a skill in there, what saves it?

The method used currently is very manual as shown in the code below:

Code:
steeddata = { };


steeddata[0] = "0x7001BFFE"; -- Bree-Starter Horse
steeddata[1] = "0x7001B4B7"; -- Bay Horse
steeddata[2] = "0x7001B4C9"; -- Blonde Sorrel Horse
steeddata[3] = "0x7001B4B0"; -- Bloodbay Horse
steeddata[4] = "0x7001B4C5"; -- Chestnut Horse
steeddata[5] = "0x7001B4A8"; -- Springfest Horse
steeddata[6] = "0x70020550"; -- Blue Roan Horse
steeddata[7] = "0x7001B4C7"; -- Lithe Festival Horse
steeddata[8] = "0x700216F9"; -- Pale Golden Summer Horse
steeddata[9] = "0x7001B4C0"; -- Harvestmath Horse
steeddata[10] = "0x7001B4CD"; -- Yule Festival Horse
steeddata[11] = "0x7001E8EE"; -- Yule Festival Snow Horse
steeddata[12] = "0x7001CF5D"; -- Liver Chestnut Horse
steeddata[13] = "0x7001B4AC"; -- Dark Chestnut Horse
steeddata[14] = "0x7001B4D3"; -- Tundra-Horse
steeddata[15] = "0x7001B4C4"; -- Ashen Horse
steeddata[16] = "0x7001B4D9"; -- Grey Horse
steeddata[17] = "0x7001B4D0"; -- Galadhrim Horse
steeddata[18] = "0x7002054D"; -- Smoky Black Horse
steeddata[19] = "0x70022C61"; -- Horse of the Grey Company
steeddata[20] = "0x7001E97D"; -- Dunedain War-Horse
steeddata[21] = "0x7001B4B1"; -- Mahogany Bay Horse
steeddata[22] = "0x7001E980"; -- Galadhrim War-Horse
steeddata[23] = "0x7001E8ED"; -- Sable Harvestmath Horse
steeddata[24] = "0x7001B4C1"; -- Bree Horse

steedqs = { };

for i = 0, 24 do

	steedqs[i] = Turbine.UI.Lotro.Quickslot();
	steedqs[i]:SetShortcut( Turbine.UI.Lotro.Shortcut( 6.0, steeddata[i] ) );

end

goatdata = { };

goatdata[0] = "0x7001CEAA"; -- Dusky Nimblefoot Goat
goatdata[1] = "0x7001B4B4"; -- Tame Redhorn Goat 
goatdata[2] = "0x7001B4B8"; -- Nimble Redhorn-Goat
goatdata[3] = "0x7001E981"; -- Nimble Black Goat
goatdata[4] = "0x7001E97A"; -- Wild Mountain Goat

goatqs = { };

for i = 0, 4 do

	goatqs[i] = Turbine.UI.Lotro.Quickslot();
	goatqs[i]:SetShortcut( Turbine.UI.Lotro.Shortcut( 6.0, goatdata[i] ) );
I understand that the { } signify data in a table, but again, not sure the best way to allow someone to drop a quickslot into the center quickslot of the carousel, add that to the table and save, and then allow other items to be dropped into the carousel and keep increasing the number of slots on the carousel each time.
Reply With Quote
  #5  
Unread 01-06-2011, 07:30 PM
Marll's Avatar
Marll Marll is offline
The Undying
Interface Author - Click to view interfaces
 
Join Date: Jan 2010
Posts: 51
So, I'm having an all new, fun problem. I've started to restructure my code and attempt to make notes in each section to get a better idea of what each block of code is doing.

Below is the code that I have currently, which should set up the quickslots (I think LOL) but when I load it into LOTRO the plugin manager shows that it is loaded but I see now window or quickslots. What could I be doing wrong?

Code:
import "Turbine.UI";
import "Turbine.UI.Lotro";
import "Turbine.UI.Extensions";

import "RogidorPlugins.MountCarousel";

-- ==================================================================================================================
--			Load Function
--
-- ================================================================================================================== 
function LoadSettings()

settings = Turbine.PluginData.Load( Turbine.DataScope.Character, "MountCarouselSettings" );

	if ( type( settings ) ~= "table" ) then
		settings = { };
	end
	
	if ( not settings.welcome ) then
		settings.welcome = false;
	end

	if ( not settings.positionX ) then		
		settings.positionX = ( Turbine.UI.Display.GetWidth() - mainWindow:GetWidth() - edgePadding);		
	end
	
	if ( not settings.positionY ) then	
		settings.positionY = ( Turbine.UI.Display.GetHeight() - mainWindow:GetHeight() - edgePadding * 1.5 );
	end
	
	if ( not settings.alwayshide ) then
		settings.alwayshide = false;
	end
	
	if ( not settings.goat ) then
		settings.goat = false;
	end
	
	if ( not settings.qs1 ) then
		settings.qs1 = 0;
	end
	
	if ( not settings.qs2 ) then
		settings.qs2 = 1;
	end
	
	if ( not settings.qs3 ) then
		settings.qs3 = 2;
	end

	if ( not settings.cqs1 ) then
		settings.cqs1 = 0;
	end
	
	if ( not settings.cqs2 ) then
		settings.cqs2 = 1;
	end
	
	if ( not settings.cqs3 ) then
		settings.cqs3 = 2;
	end

end

-- =====================================================================================================================
--			Save Function
--
-- =====================================================================================================================

function SaveSettings()

Turbine.PluginData.Save( Turbine.DataScope.Character, "MountCarouselSettings", settings );

end

-- =======================================================================================================================
--			Save data on unload
--
-- =======================================================================================================================
if ( Plugins ["MountCarousel"] ~= nil ) then
	Plugins["MountCarousel"].Unload = function( sender, args )
		SaveSettings();
		Turbine.Shell.WriteLine("Mount Carousel Data Saved!")
	end
end

-- ========================================================================================================================
--			Creation of the Main "Mounts" Window in which to display the carousel of quickslots
--
-- ========================================================================================================================
edgePadding = 50;

mainWindow = Turbine.UI.Extensions.Window();
mainWindow:SetSize( 200 , 35 );
mainWindow:SetText("Mounts");
mainWindow:SetOpacity( 0 );
mainWindow:SetFadeSpeed( 0.5 );
mainWindow:SetVisible( true );

LoadSettings();

mainWindow:SetPosition(settings.positionX, settings.positionY);

-- ========================================================================================================================
--			Creation of the individual parent windows to house each of the quickslots in the carousel
--
-- ========================================================================================================================
farleftWindow = Turbine.UI.Extensions.SimpleWindow();
farleftWindow:SetSize( 35 , 35 );
farleftWindow:SetParent( mainWindow );
farleftWindow:SetPosition( 12.5, 60 );
farleftWindow:SetOpacity( 0.25 );
farleftWindow:SetFadeSpeed( 0.5 );
farleftWindow:SetVisible( true );

leftWindow = Turbine.UI.Extensions.SimpleWindow();
leftWindow:SetSize( 35 , 35 );
leftWindow:SetParent( mainWindow );
leftWindow:SetPosition( 47.5, 50 );
leftWindow:SetOpacity( 0.25 );
leftWindow:SetFadeSpeed( 0.5 );
leftWindow:SetVisible( true );

centerWindow = Turbine.UI.Extensions.SimpleWindow();
centerWindow:SetSize( 35 , 35 );
centerWindow:SetParent( mainWindow );
centerWindow:SetPosition( 82.5, 40 );
centerWindow:SetVisible( true );
centerWindow:SetAllowDrop( true );

rightWindow = Turbine.UI.Extensions.SimpleWindow();
rightWindow:SetSize( 35 , 35 );
rightWindow:SetParent( mainWindow );
rightWindow:SetPosition( 117.5, 50 );
rightWindow:SetOpacity( 0.25 );
rightWindow:SetFadeSpeed( 0.5 );
rightWindow:SetVisible( true );

farrightWindow = Turbine.UI.Extensions.SimpleWindow();
farrightWindow:SetSize( 35 , 35 );
farrightWindow:SetParent( mainWindow );
farrightWindow:SetPosition( 152.5, 60 );
farrightWindow:SetOpacity( 0.25 );
farrightWindow:SetFadeSpeed( 0.5 );
farrightWindow:SetVisible( true );

-- ===================================================================================================================
--			Creation of each of the quickslots to be displayed in the carousel
--
-- ===================================================================================================================
farleftqs = Turbine.UI.Lotro.Quickslot();
farleftqs:SetParent( farleftWindow );
farleftqs:SetPosition( 0, 0 );
farleftqs:SetSize( 35, 35 );
farleftqs:SetAllowDrop(false);

leftqs = Turbine.UI.Lotro.Quickslot();
leftqs:SetParent( leftWindow );
leftqs:SetPosition( 0, 0 );
leftqs:SetSize( 35, 35 );
leftqs:SetAllowDrop(false);

centerqs = Turbine.UI.Lotro.Quickslot();
centerqs:SetParent( centerWindow );
centerqs:SetPosition( 0, 0 );
centerqs:SetSize( 35, 35 );
centerqs:SetAllowDrop( true );
quickslot:SetUseOnRightClick( false );

rightqs = Turbine.UI.Lotro.Quickslot();
rightqs:SetParent( rightWindow );
rightqs:SetPosition( 0, 0 );
rightqs:SetSize( 35, 35 );
rightqs:SetAllowDrop(false);

farrightqs = Turbine.UI.Lotro.Quickslot();
farrightqs:SetParent( farrightWindow );
farrightqs:SetPosition( 0, 0 );
farrightqs:SetSize( 35, 35 );
farrightqs:SetAllowDrop(false);
Reply With Quote
  #6  
Unread 01-06-2011, 08:46 PM
Kragenwar Kragenwar is offline
The Undying
Interface Author - Click to view interfaces
 
Join Date: Sep 2010
Posts: 26
Your mainWindow opacity appears to be 0, making th window housing all the slots to be invisible, which also makes the slots invisible.
Reply With Quote
  #7  
Unread 01-07-2011, 12:39 PM
Marll's Avatar
Marll Marll is offline
The Undying
Interface Author - Click to view interfaces
 
Join Date: Jan 2010
Posts: 51
Strange thing is that it's always been that way even on the original code in Paulino's Pet Carousel, the opacity of the window was set to 0 and it still shows.

Anything else that might cause it in that code? I'll change the opacity and see if it makes a difference when I can next though, thanks for looking at it and the advice, appreciate it! I'm sure I'll have plenty more questions before I'm done. Was almost ready to give up, but just can't let it go until this is working the way I want.
Reply With Quote
  #8  
Unread 01-07-2011, 01:17 PM
Kragenwar Kragenwar is offline
The Undying
Interface Author - Click to view interfaces
 
Join Date: Sep 2010
Posts: 26
If what you posted is the whole code block then the opacity might be the issue, I don't have paulinos code in front of me but I believe after initial load he fades up the mainwindow. So if you took just the code that creates the windows and slots but not the cod that fades it up, your window would be invisible.
Reply With Quote
  #9  
Unread 01-07-2011, 02:09 PM
Marll's Avatar
Marll Marll is offline
The Undying
Interface Author - Click to view interfaces
 
Join Date: Jan 2010
Posts: 51
Hrm, maybe this is what was missing, but I'm not sure how it ended up removed from my code. This seems to set the opacity of the window conditionally based on mouse over or the always hide attribute being set:

Code:
mainWindow.MouseEnter = function( sender, args )

if (alwayshide == false) then
	mainWindow:SetOpacity( 0.75 );
end

rightWindow:SetOpacity( 0.75 );
leftWindow:SetOpacity( 0.75 );
releaseWindow:SetOpacity( 0.75 );

end

mainWindow.MouseLeave = function( sender, args )

X, Y = mainWindow:GetPosition();

if (alwayshide == false) then
	mainWindow:SetOpacity( 0 );
end

rightWindow:SetOpacity( 0.25 );
leftWindow:SetOpacity( 0.25 );
releaseWindow:SetOpacity( 0.25 );

if ( X ~= settings.positionX or Y ~= settings.positionY ) then
		
	settings.positionX = X;
	settings.positionY = Y;
	SaveSettings();
		
end

end
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
LocalPlayer (a table value)? WTH goldbishop Lua Programming Help (L) 4 11-30-2010 05:13 PM
nested table issues SanDBoX Lua Programming Help (L) 1 11-21-2010 02:12 AM
Interface into game data Aran Interface Help (D) 1 11-11-2010 12:38 AM
Frosty - Client Side Layout Data, Please! Erythor LotRO Wish List (L) 10 01-31-2009 06:07 AM
Whats on the table post retail launch? AncientWolf General Authoring Discussion (L) 10 04-27-2007 07:11 AM


All times are GMT -5. The time now is 08:25 AM.


Our Network
EQInterface | EQ2Interface | Minion | WoWInterface | ESOUI | LoTROInterface | MMOUI | Swtorui