From 644fb6b013b8c8598c42d19cee67201911f31c2e Mon Sep 17 00:00:00 2001 From: Mic Bowman Date: Fri, 20 Jul 2012 10:25:50 -0700 Subject: [PATCH 1/2] Implements a very useful OSSL function to test a string to see if it is a UUID. The function is osIsUUID(). Thanks SignpostMarv! --- .../Shared/Api/Implementation/OSSL_Api.cs | 14 ++++++++++++++ .../ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs | 7 +++++++ .../ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs | 5 +++++ 3 files changed, 26 insertions(+) diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs index 413739776f..e0b4db62dc 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs @@ -3274,5 +3274,19 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api InitLSL(); ((LSL_Api)m_LSL_Api).DetachFromAvatar(); } + + /// + /// Checks if thing is a UUID. + /// + /// + /// 1 if thing is a valid UUID, 0 otherwise + public LSL_Integer osIsUUID(string thing) + { + CheckThreatLevel(ThreatLevel.None, "osIsUUID"); + m_host.AddScriptLPS(1); + + UUID test; + return UUID.TryParse(thing, out test) ? 1 : 0; + } } } \ No newline at end of file diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs index b5416c8b0e..c9403ebc29 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs @@ -276,5 +276,12 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces void osSetTerrainTexture(int level, LSL_Key texture); void osSetTerrainTextureHeight(int corner, double low, double high); + + /// + /// Checks if thing is a UUID. + /// + /// + /// 1 if thing is a valid UUID, 0 otherwise + LSL_Integer osIsUUID(string thing); } } diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs index b40bdf0b17..99995a7171 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs @@ -930,5 +930,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase { m_OSSL_Functions.osSetTerrainTextureHeight(corner, low, high); } + + public LSL_Integer osIsUUID(string thing) + { + return m_OSSL_Functions.osIsUUID(thing); + } } } From a4281ca014c80ca516e514e9fde9bb3a13e10c97 Mon Sep 17 00:00:00 2001 From: Mic Bowman Date: Fri, 20 Jul 2012 10:48:51 -0700 Subject: [PATCH 2/2] Enables support for UUIDs to be returned in lists from modInvoke commands. Thanks SignpostMarv!!! --- .../Shared/Api/Implementation/MOD_Api.cs | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/MOD_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/MOD_Api.cs index 4bd3dffd30..7844c75155 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/MOD_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/MOD_Api.cs @@ -200,24 +200,34 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api for (int i = 0; i < result.Length; i++) { if (result[i] is string) + { llist[i] = new LSL_String((string)result[i]); + } else if (result[i] is int) + { llist[i] = new LSL_Integer((int)result[i]); + } else if (result[i] is float) + { llist[i] = new LSL_Float((float)result[i]); + } + else if (result[i] is UUID) + { + llist[i] = new LSL_Key(result[i].ToString()); + } else if (result[i] is OpenMetaverse.Vector3) { OpenMetaverse.Vector3 vresult = (OpenMetaverse.Vector3)result[i]; - llist[i] = new LSL_Vector(vresult.X,vresult.Y,vresult.Z); + llist[i] = new LSL_Vector(vresult.X, vresult.Y, vresult.Z); } else if (result[i] is OpenMetaverse.Quaternion) { OpenMetaverse.Quaternion qresult = (OpenMetaverse.Quaternion)result[i]; - llist[i] = new LSL_Rotation(qresult.X,qresult.Y,qresult.Z,qresult.W); + llist[i] = new LSL_Rotation(qresult.X, qresult.Y, qresult.Z, qresult.W); } else { - MODError(String.Format("unknown list element returned by {0}",fname)); + MODError(String.Format("unknown list element {1} returned by {0}", fname, result[i].GetType().Name)); } }