import "Turbine"
import "Turbine.UI"
import "Turbine.UI.Lotro"
import "Turbine.Gameplay"
import "Deusdictum.UI.Dragbar"
import"JackdawPlugins.SortPack.functions"
import "JackdawPlugins.SortPack.main"
player = Turbine.Gameplay.LocalPlayer.GetInstance()
backpack = player:GetBackpack()
size =backpack:GetSize()
if not pcall(function() import "JackdawPlugins.Patch.Patch" end) then
--Turbine.Shell.WriteLine("Patch not present - default Load and Save used")
JackdawPlugins.Patch={}
function JackdawPlugins.Patch.Load(a,b,c) return Turbine.PluginData.Load(a,b,c) end
function JackdawPlugins.Patch.Save(a,b,c,d) Turbine.PluginData.Save(a,b,c,d) end
end
SortCommand = Turbine.ShellCommand()
function SortCommand:Execute(command, i)
Turbine.Shell.WriteLine("<rgb=#888888>Starting sort")
Sort()
end
Turbine.Shell.AddCommand('Sort', SortCommand)
OptionCommand = Turbine.ShellCommand()
function OptionCommand:Execute(command, i)
import"JackdawPlugins.SortPack.ListOption"
ShowListOption()
end
Turbine.Shell.AddCommand('SortOption', OptionCommand)
HideCommand = Turbine.ShellCommand()
function HideCommand:Execute(command, i)
SortButtonData.Hide=not(SortButtonData.Hide)
SortButton.Window:SetVisible(not(SortButtonData.Hide))
end
Turbine.Shell.AddCommand('SortHide', HideCommand)
DebugCommand = Turbine.ShellCommand()
function DebugCommand:Execute(command, i)
import"JackdawPlugins.SortPack.Debug"
Debug()
end
Turbine.Shell.AddCommand('SortDebug', DebugCommand)
SortBagCommand = Turbine.ShellCommand()
function SortBagCommand:Execute(command, i)
openbag()
end
Turbine.Shell.AddCommand('openbag', SortBagCommand)
local Player = player:GetName()
local savedata=JackdawPlugins.Patch.Load( Turbine.DataScope.Server, "SortPackData" )
if savedata~=nil then
Groups=savedata.Groups
if Groups==nil then Turbine.Shell.WriteLine("I am sorry, this new version of Sortpack uses groups and your old data has been lost. Please right click the SortPack icon to restore your order and see the new feature that makes this easier.") end
if savedata[Player]~=nil then SortButtonData=savedata[Player].SortButtonData SB=savedata[Player].SB end
else
savedata={}
end
import"JackdawPlugins.SortPack.List"
import "JackdawPlugins.SortPack.bag"
import"JackdawPlugins.SortPack.Button"
Plugins["SortPack"].Unload = function( sender, args )
Turbine.Shell.WriteLine("<rgb=#888888>Saved Sort Pack Data")
SortButtonData.X,SortButtonData.Y=SortButton.Window:GetPosition()
local Player = Turbine.Gameplay.LocalPlayer.GetInstance():GetName()
savedata.list=nil
savedata.Groups=Groups
savedata[Player]={}
savedata[Player].SortButtonData={SortButtonData.X,SortButtonData.Y,SortButtonData.Scale,SortButtonData.Hide}
savedata[Player].SB=SB
JackdawPlugins.Patch.Save( Turbine.DataScope.Server, "SortPackData", savedata )
end