|
11-12-2011, 10:25 AM
|
|
The Indomitable
|
|
Join Date: May 2011
Posts: 13
|
|
Saving and loading help
Hiya,
For Kmabc 1.2 i am implementing saving and loading. But however, i am at a standstill . I am trying to save quickslot data to the plugindata but cannot get anywhere. the code so far is:
Code:
local savedatax ={
quickslot1SavData = "",
quickslot2SavData = "",
quickslot3SavData = "",
quickslot4SavData = "",
quickslot5SavData = "",
quickslot6SavData = "",
quickslot7SavData = "",
quickslot8SavData = "",
quickslot9SavData = "",
}
and
Code:
Save.Click = function( sender , args )
savedatax.quickslot1SavData = quickslot1:GetShortcut();
savedatax.quickslot2SavData = quickslot2:GetShortcut();
savedatax.quickslot3SavData = quickslot3:GetShortcut();
savedatax.quickslot4SavData = quickslot4:GetShortcut();
savedatax.quickslot5SavData = quickslot5:GetShortcut();
savedatax.quickslot6SavData = quickslot6:GetShortcut();
savedatax.quickslot7SavData = quickslot7:GetShortcut();
savedatax.quickslot8SavData = quickslot8:GetShortcut();
savedatax.quickslot9SavData = quickslot9:GetShortcut();
Turbine.Shell.WriteLine("Pre Save");
Turbine.PluginData.Save(Turbine.DataScope.Character, "KmabcSaveData", savedatax); --
Turbine.Shell.WriteLine("Post Save");
end
can anyone point me in the right direction please
thanks Queekusme
PS. i get the file with the names in but no value to put into them.
PPS. i know how to put plain text into the savedata file but not quickslot data so i request that people dont tell me this.
__________________
We create that what only we love most, But what truly creates us is what(who) loves us the most. - ME, i'm philosopher nao
Where's Chuck Norris' plugin?
|
11-12-2011, 11:20 AM
|
|
The Undefeated
|
|
Join Date: Sep 2010
Posts: 5
|
|
the reason that is not working is because :GetShortcut() returns the class Turbine.UI.Lotro.Shortcut
which isn't the data you want
this is what i do
Code:
quickslot.ShortcutChanged = function(sender, args)
local shortcut = sender:GetShortcut()
local type, data = shortcut:GetType(), shortcut:GetData()
if type == Turbine.UI.Lotro.ShortcutType.Undef then
DB.quickslots[sender._index] = nil
else
DB.quickslots[sender._index] = {type, data}
end
end
--and to load the data
if DB.quickslots[quickslot._index] then
quickslot:SetShortcut(Turbine.UI.Lotro.Shortcut(DB.quickslots[quickslot._index][1], DB.quickslots[quickslot._index][2]))
end
--quickslot._index is something i set to show what slot it represented
|
11-12-2011, 02:12 PM
|
|
The Indomitable
|
|
Join Date: May 2011
Posts: 13
|
|
I dont really understand this, what i want to do is save the data to the file so that it puts a hexcode there... how can i use this to make it do that?
__________________
We create that what only we love most, But what truly creates us is what(who) loves us the most. - ME, i'm philosopher nao
Where's Chuck Norris' plugin?
|
11-12-2011, 04:54 PM
|
|
The Undying
|
|
Join Date: Feb 2009
Location: Lancaster, England
Posts: 249
|
|
Quote:
local type, data = shortcut:GetType(), shortcut:GetData()
|
Is the important part here and the data you need - this is the hex code for the skill and the type of skill. These are also what you use when you set a skill.
Do you use a bar plugin at all? If you do you should be able to extract the codes you need from its save data.
Alternatively
Quote:
shortcut= quickslot:GetShortcut()
type, data = shortcut:GetType(), shortcut:GetData()
|
Will get you the data you need from one quickslot that you build. Obviously, save etc as you wish!
__________________
************************************************** ************************************************** **
"Our ideals may never be realised, But they indicate what we are trying to do." Dick Tahta
Last edited by MrJackdaw : 11-12-2011 at 06:11 PM.
|
11-13-2011, 06:04 AM
|
|
The Indomitable
|
|
Join Date: May 2011
Posts: 13
|
|
So how do i put that in the context of my code is it something like
Code:
local savedatax ={
shortcut = quickslot1:GetShortcut()
local type, data = shortcut:GetType(), shortcut:GetData()
quickslot1SavData = type,data,
-- And then copy for the other shortcuts...
}
and to load it (copied from Cearbhall)
Code:
quickslot1:SetShortcut(Turbine.UI.Lotro.Shortcut(type value,data value)) -- type and data values called from the loadup process
__________________
We create that what only we love most, But what truly creates us is what(who) loves us the most. - ME, i'm philosopher nao
Where's Chuck Norris' plugin?
Last edited by Queekusme : 11-13-2011 at 06:09 AM.
|
11-13-2011, 09:43 AM
|
|
The Undying
|
|
Join Date: Oct 2010
Posts: 346
|
|
Quote:
Originally Posted by Queekusme
Code:
quickslot1:SetShortcut(Turbine.UI.Lotro.Shortcut(type value,data value)) -- type and data values called from the loadup process
|
If there is any chance that your saved quickslot data could have an Alias type shortcut, you can run into a Turbine bug using the default Shortcut constructor with international characters. To avoid that issue with german and french users, use the :SetData() method to set the shortcut like:
Code:
local sc=Turbine.UI.Lotro.Shortcut();
sc:SetType(typeValue);
sc:SetData(dataValue); -- works with international characters
Quickslot1:SetShortcut(sc);
It's not as pretty but it avoids the international character bug in the constructor. You should also be using some form of encoding for your save data and load data routines (I use Vindar's patch available here on LoTROInterface.com)
|
11-13-2011, 01:42 PM
|
|
The Indomitable
|
|
Join Date: May 2011
Posts: 13
|
|
Thanks for the help, i'll try this tomorrow, and i'll look into vindir....'s patch as encoding allways helps
thanks again
Queekusme
EDIT: thanks again for this but i never intended for there to be alias strings to be saved anyway, but thanks as this will prevent people complaining
__________________
We create that what only we love most, But what truly creates us is what(who) loves us the most. - ME, i'm philosopher nao
Where's Chuck Norris' plugin?
Last edited by Queekusme : 11-13-2011 at 01:58 PM.
|
11-13-2011, 08:30 PM
|
The Undying
|
|
Join Date: Apr 2011
Posts: 52
|
|
Quote:
Originally Posted by Queekusme
So how do i put that in the context of my code is it something like
Code:
local savedatax ={
shortcut = quickslot1:GetShortcut()
local type, data = shortcut:GetType(), shortcut:GetData()
quickslot1SavData = type,data,
-- And then copy for the other shortcuts...
}
|
That wouldn't work.
If you write "a,b = x,y" a is set to the value of x and b is set the value of y. If you write "a =x,y" a is set to the value of x and y is discarded.
In your case, 'quickslot1SavData' would be set to the value of 'type' and 'data' would be discarded.
You could however, make your quickslotxSavData tables then set both type & data:
Code:
quickslot1SavData = {}
quickslot2SavData = {}
...
Code:
(...)
quickslot1SavData.type, quickslot1SavData.data = type, data
(...)
|
11-14-2011, 11:08 AM
|
|
The Indomitable
|
|
Join Date: May 2011
Posts: 13
|
|
So what you're saying is that i should save each piece seperately insted of in the same piece of information string.
i see where you are getting at, ok, i'll try this after my tea and homework tonight
__________________
We create that what only we love most, But what truly creates us is what(who) loves us the most. - ME, i'm philosopher nao
Where's Chuck Norris' plugin?
|
11-14-2011, 04:07 PM
|
The Undying
|
|
Join Date: Apr 2011
Posts: 52
|
|
Quote:
Originally Posted by Queekusme
So what you're saying is that i should save each piece seperately insted of in the same piece of information string.
|
Well, you *can't* set one variable to two values.
If you write "quickslot1SavData = type,data", what the lua runtime does is "quickslot1SavData = type", and then it discards 'data'.
See Lua Reference Manual
Quote:
Before the assignment, the list of values is adjusted to the length of the list of variables. If there are more values than needed, the excess values are thrown away. If there are fewer values than needed, the list is extended with as many nil's as needed.
|
Last edited by Equendil : 11-14-2011 at 04:12 PM.
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
All times are GMT -5. The time now is 03:32 AM.
|
|