Saving window position
I am trying to figure out how to save window position so that it is persistent through a reload.
I think that I should have it write its coordinates to a save file when it is being dragged and the mouse button is released, but I can not for the life of me figure out how to write that code. Any help is greatly appreciated. |
Isn't that what the "layout system" has brought into action for?
http://lorebook.lotro.com/wiki/Relea...ook_8_Official # The client now has a /ui command that can be used to save the current layout of windows to an xml file and then load this layout. # To save a ui layout type: /ui layout save <name> # To load a previously saved layout: /ui layout load <name> # In both cases the name is optional and if not specified it will just save to a file called Default_ appended with your current game window resolution. (e.q running in 800 x 600 results inDefault_800_600.layout) Or were you talking about something else? |
(Bear with me, still learning Lua)
When you press "Ctrl + \" it doesn't give a handle to set the Lua window position. I tried writing a function that basically says if the window changes position to save the coordinates to a file and when the window is recalled to load those coordinates . I just haven't been successful as of yet. |
Assuming the window is called "Window" and the place you want to store the data is a table called "Data";
Code:
Window.PositionChanged=function(sender,args) Then, when you load the data - just use the Data.x and Data.y to load in the position. Assumption: You are saving the data at some point with; Code:
Turbine.PluginData.Save( Turbine.DataScope.Character, "The Name of Your Plugin", Data ); Code:
Data=Turbine.PluginData.Load( Turbine.DataScope.Character, "The Name of Your Plugin") |
Thanks, but I am still a little lost. What I have been trying to add is a code that looks to see if the data file exists and if it does use that position. If it doesn't then it uses a default set of values. I am still not sure where all of this goes.
I tried to start simple...this is what I have been trying (without the checking to see if the file exists or not) Code:
SatchelWindow = class( Turbine.UI.Window ); I guess its off to borders to find an Lua book... |
Thinking on my feet but change the "Window" lines to "self" as "self" is the window. And don't waste money in Borders - I worked my way through the Turbine sample stuff stealing where I could, especially the combat bar on. Just as with learing the xml modification stuff, look at other peoples work and rip it apart... *grin* The excellent lessons on http://www.lua.org/pil/ helped me get a bit better!
I still wouldn't call myself any good - but the stuff works well enough for me! |
I changed both of my Window values to self, but i am still getting the error;
attempt to index Global 'Data' (a nil value) |
Has Data been defined anywhere as a value? If there are no saved variables it becomes "nil" and effectively does not exist.
Add this after the load line; if Data==nil then Data={} end and that should sort it! Note the "==" not just "=". I always get that wrong! If you are defining it is a single =, if you are comparing it is a double ==. |
I was under the assumption that
Code:
Data = Turbine.PluginData.Load( Turbine.DataScope.Character, "SatchelData") Here is all of my code thus far... Code:
|
Move your declaration of Data so that it's below the constructor lines
add "self." in front of Data Code:
SatchelWindow = class( Turbine.UI.Window ); |
All times are GMT -5. The time now is 11:41 PM. |
vBulletin® - Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
© MMOUI