adds new SendFolderByPath command
This commit is contained in:
parent
06c5d5cbe2
commit
c338b9c617
2 changed files with 78 additions and 0 deletions
|
|
@ -392,6 +392,28 @@ namespace SecondBotEvents.Commands
|
|||
GetClient().Inventory.GiveItem(itm.UUID, itm.Name, itm.AssetType, avataruuid, false);
|
||||
return BasicReply("ok", new [] { item, avatar });
|
||||
}
|
||||
[About("Sends a folder to an avatar")]
|
||||
[ReturnHints("ok")]
|
||||
[ReturnHints("Invaild avatar uuid")]
|
||||
[ReturnHints("Unable to find folder")]
|
||||
[ArgHints("path", "path to the folder from root")]
|
||||
[ArgHints("avatar", "a UUID or Firstname Lastname")]
|
||||
public object SendFolderByPath(string path, string avatar)
|
||||
{
|
||||
ProcessAvatar(avatar);
|
||||
if (avataruuid == UUID.Zero)
|
||||
{
|
||||
return Failure("Invaild avatar uuid", new[] { path, avatar });
|
||||
}
|
||||
InventoryFolder FindFolderHelper = HelperInventory.FindFolderByPath(GetClient(), path);
|
||||
if (FindFolderHelper == null)
|
||||
{
|
||||
return Failure("Unable to find folder", new[] { path, avatar });
|
||||
}
|
||||
GetClient().Inventory.GiveFolder(FindFolderHelper.UUID, FindFolderHelper.Name, avataruuid, false);
|
||||
return BasicReply("ok", new[] { path, avatar });
|
||||
}
|
||||
|
||||
|
||||
[About("Sends a folder to an avatar")]
|
||||
[ReturnHints("ok")]
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
using Newtonsoft.Json;
|
||||
using OpenMetaverse;
|
||||
using OpenMetaverse.ImportExport.Collada14;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
|
@ -34,6 +35,61 @@ namespace BetterSecondBot.Static
|
|||
}
|
||||
return UUID.Zero;
|
||||
}
|
||||
|
||||
public static InventoryFolder FindFolderByPath(GridClient bot, string path)
|
||||
{
|
||||
return DigFolderForPath(bot, path, 0, bot.Inventory.Store.RootFolder.UUID);
|
||||
}
|
||||
|
||||
private static InventoryFolder DigFolderForPath(GridClient bot, string path, int level, UUID folder)
|
||||
{
|
||||
string[] bits = path.Split('/');
|
||||
List<InventoryBase> T = bot.Inventory.Store.GetContents(folder);
|
||||
InventoryFolder foundFolder = null;
|
||||
bool found = false;
|
||||
foreach (InventoryBase t in T)
|
||||
{
|
||||
if (t.GetType() == typeof(InventoryFolder))
|
||||
{
|
||||
if (t.Name == bits[level])
|
||||
{
|
||||
folder = t.UUID;
|
||||
if (bits.Length > (level+1))
|
||||
{
|
||||
// need to go deeper
|
||||
foundFolder = DigFolderForPath(bot, path, level + 1, folder);
|
||||
if (foundFolder != null)
|
||||
{
|
||||
found = true;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// we are here
|
||||
foundFolder = (InventoryFolder)t;
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
continue;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
continue;
|
||||
}
|
||||
}
|
||||
if(found == true)
|
||||
{
|
||||
return foundFolder;
|
||||
}
|
||||
else
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
public static InventoryBase FindFolder(GridClient bot, InventoryFolder current,UUID target)
|
||||
{
|
||||
List<InventoryBase> T = bot.Inventory.Store.GetContents(current);
|
||||
|
|
|
|||
Loading…
Reference in a new issue