diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs index 1a89929d9e..46b4233137 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs @@ -6807,5 +6807,84 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api } return -1; } + public LSL_Float osListAsFloat(LSL_List src, int index) + { + object[] data = src.Data; + if(data == null) + return LSL_Integer.Zero; + if (index >= 0 && index < data.Length) + { + object o = data[index]; + if(o is LSL_Float d) + return d; + if(o is double nd) + return nd; + } + return LSL_Float.Zero; + } + + public LSL_Integer osListAsInteger(LSL_List src, int index) + { + object[] data = src.Data; + if(data == null) + return LSL_Integer.Zero; + if (index >= 0 && index < data.Length) + { + object o = data[index]; + if(o is LSL_Integer i) + return i; + if(o is int ni) + return ni; + } + return LSL_Integer.Zero; + } + + public LSL_String osListAsString(LSL_List src, int index) + { + object[] data = src.Data; + if(data == null) + return LSL_String.Empty; + if (index >= 0 && index < data.Length) + { + object o = data[index]; + if(o is LSL_String s) + return s; + if(o is string ns) + return ns; + } + return LSL_String.Empty; + } + + public LSL_Vector osListAsVector(LSL_List src, int index) + { + object[] data = src.Data; + if(data == null) + return LSL_Vector.Zero; + if (index >= 0 && index < data.Length) + { + object o = data[index]; + if(o is LSL_Vector v) + return v; + if(o is Vector3 ov) + return ov; + } + return LSL_Vector.Zero; + } + + public LSL_Rotation osListAsRotation(LSL_List src, int index) + { + object[] data = src.Data; + if(data == null) + return LSL_Rotation.Identity; + if (index >= 0 && index < data.Length) + { + object o = data[index]; + if(o is LSL_Rotation r) + return r; + if(o is Quaternion q) + return q; + } + return LSL_Rotation.Identity; + } } } \ 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 e6c2456e7c..addb1eb4e9 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs @@ -924,5 +924,15 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces /// a integer with index of match point or -1 //ApiDesc Returns the nth index of the sublist constrained with start and end count. LSL_Integer osListFindListNext(LSL_List src, LSL_List test, LSL_Integer start, LSL_Integer end, LSL_Integer instance); + //ApiDesc Returns a string that is at index(>=0) in src or empty string if that is not a string + LSL_String osListAsString(LSL_List src, int index); + //ApiDesc Returns a integer that is at index(>=0) in src or 0 if that is not a integer + LSL_Integer osListAsInteger(LSL_List src, int index); + //ApiDesc Returns a float that is at index(>=0) in src or 0 if that is not a float + LSL_Float osListAsFloat(LSL_List src, int index); + //ApiDesc Returns a vector that is at index(>=0) in src or Zero vector if that is not a vector + vector osListAsVector(LSL_List src, int index); + //ApiDesc Returns a rotation that is at index(>=0) in src or zero rotation if that is not a vector + LSL_Rotation osListAsRotation(LSL_List src, int index); } } diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs index c5703efc88..3ce1ee56eb 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs @@ -1831,5 +1831,35 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase { return m_OSSL_Functions.osListFindListNext(src, test, start, end, instance); } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public LSL_String osListAsString(LSL_List src, int index) + { + return m_OSSL_Functions.osListAsString(src, index); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public LSL_Integer osListAsInteger(LSL_List src, int index) + { + return m_OSSL_Functions.osListAsInteger(src, index); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public LSL_Float osListAsFloat(LSL_List src, int index) + { + return m_OSSL_Functions.osListAsFloat(src, index); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public vector osListAsVector(LSL_List src, int index) + { + return m_OSSL_Functions.osListAsVector(src, index); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public rotation osListAsRotation(LSL_List src, int index) + { + return m_OSSL_Functions.osListAsRotation(src, index); + } } }