import "JackdawPlugins.SortPack.main"
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)
import "Turbine.Gameplay"
local Player = Turbine.Gameplay.LocalPlayer.GetInstance():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";
if SortButtonData==nil then
SortButtonData={X=100,Y=100,Scale=0.5}
else
SortButtonData.X,SortButtonData.Y,SortButtonData.Scale,SortButtonData.Hide=SortButtonData[1],SortButtonData[2],SortButtonData[3],SortButtonData[4]
end
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