From dc0d089bf504aac293d669988e4b4bdb0e1355c0 Mon Sep 17 00:00:00 2001 From: Charles Krinke Date: Tue, 24 Jun 2008 21:23:28 +0000 Subject: Mantis#5189. Thank you kindly, Matth for your patch to add the beginnings of llGiveInventory(). --- .../ScriptEngine/Common/LSL_BuiltIn_Commands.cs | 39 +++++++++++++++++++++- 1 file changed, 38 insertions(+), 1 deletion(-) (limited to 'OpenSim/Region/ScriptEngine/Common') diff --git a/OpenSim/Region/ScriptEngine/Common/LSL_BuiltIn_Commands.cs b/OpenSim/Region/ScriptEngine/Common/LSL_BuiltIn_Commands.cs index 6f4e481..a4e473d 100644 --- a/OpenSim/Region/ScriptEngine/Common/LSL_BuiltIn_Commands.cs +++ b/OpenSim/Region/ScriptEngine/Common/LSL_BuiltIn_Commands.cs @@ -35,6 +35,7 @@ using Nini.Config; using Axiom.Math; using libsecondlife; using OpenSim.Framework; +using OpenSim.Framework.Communications.Cache; using OpenSim.Region.Environment; using OpenSim.Region.Environment.Interfaces; using OpenSim.Region.Environment.Modules.Avatar.Currency.SampleMoney; @@ -2696,7 +2697,43 @@ namespace OpenSim.Region.ScriptEngine.Common public void llGiveInventory(string destination, string inventory) { m_host.AddScriptLPS(1); - NotImplemented("llGiveInventory not yet oh no!"); + bool found = false; + LLUUID destId = LLUUID.Zero; + LLUUID objId = LLUUID.Zero; + + if(!LLUUID.TryParse(destination, out destId)) + { + llSay(0, "Could not parse key " + destination); + return; + } + + // move the first object found with this inventory name + foreach (KeyValuePair inv in m_host.TaskInventory) + { + if (inv.Value.Name == inventory) + { + found = true; + objId = inv.Key; + break; + } + } + + // check if destination is an avatar + if (World.GetScenePresence(destId) != null) + { + // destination is an avatar + CachedUserInfo userInfo = + World.CommsManager.UserProfileCacheService.GetUserDetails(destId); + World.MoveTaskInventoryItem(destId,userInfo.RootFolder.ID, m_host, objId); + } + else + { + // destination is an object + World.CopyTaskInventoryItem(destId, m_host, objId); + } + + if (!found) + llSay(0, "Could not find object " + inventory); } public void llRemoveInventory(string item) -- cgit v1.1