| View Issue Details [ Jump to Notes ] | [ Issue History ] [ Print ] |
| ID | Project | Category | View Status | Date Submitted | Last Update |
| 0006110 | opensim | [REGION] Script Functions | public | 2012-07-27 09:53 | 2012-07-27 23:11 |
|
| Reporter | SignpostMarv | |
| Assigned To | justincc | |
| Priority | normal | Severity | minor | Reproducibility | N/A |
| Status | resolved | Resolution | fixed | |
| Platform | | OS | | OS Version | |
| Product Version | master (dev code) | |
| Target Version | | Fixed in Version | | |
|
| Summary | 0006110: LSL/OSSL lacks Math.Min & Math.Max implementations. |
| Description | There's no built-in implementations of Math.Min/Math.max in LSL (see http://wiki.secondlife.com/wiki/Min [^] for user-defined function implementation).
Peppering scripts with user-defined functions for trivial things like Math functions seems a little counter-productive, so here's a patch. |
| Steps To Reproduce | default
{
state_entry()
{
llOwnerSay(llList2CSV([
"\n",
osMin(0, 1), // should be 0.0
osMin(1, 0), // should be 0.0
osMin(0.0, 1.0), // should be 0.0
osMin(1.0, 0.0), // should be 0.0
"\n",
osMax(0, 1), // should be 1.0
osMax(1, 0), // should be 1.0
osMax(0.0, 1.0), // should be 1.0
osMax(1.0, 0.0), // should be 1.0
"\n",
osMax(0, osMin(1, 0.5)), // should be 0.5
osMax(0, osMin(1, -0.5)), // should be 0.0
osMax(0, osMin(1, 1.5)) // should be 1.0
]));
}
} |
| Tags | No tags attached. |
|
| Git Revision or version number | 6ee17f5b36 |
| Run Mode | Standalone (1 Region) |
| Physics Engine | BasicPhysics |
| Environment | .NET / Windows32 |
| Mono Version | None |
| Viewer | |
|
| Attached Files | min-max.patch [^] (3,567 bytes) 2012-07-27 09:53 [Show Content] [Hide Content]From 1f3bfcde3b39c5104db51498901d4d2e98918220 Mon Sep 17 00:00:00 2001
From: SignpostMarv <github@signpostmarv.name>
Date: Fri, 27 Jul 2012 10:49:47 +0100
Subject: [PATCH] LSL/OSSL lacks Math.Min & Math.Max implementations.
---
.../Shared/Api/Implementation/OSSL_Api.cs | 28 ++++++++++++++++++++++
.../ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs | 16 +++++++++++++
.../ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs | 10 ++++++++
3 files changed, 54 insertions(+)
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs
index e0b4db6..06c4256 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs
@@ -3288,5 +3288,33 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
UUID test;
return UUID.TryParse(thing, out test) ? 1 : 0;
}
+
+ /// <summary>
+ /// Wraps to Math.Min()
+ /// </summary>
+ /// <param name="a"></param>
+ /// <param name="b"></param>
+ /// <returns></returns>
+ public LSL_Float osMin(double a, double b)
+ {
+ CheckThreatLevel(ThreatLevel.None, "osMin");
+ m_host.AddScriptLPS(1);
+
+ return Math.Min(a, b);
+ }
+
+ /// <summary>
+ /// Wraps to Math.max()
+ /// </summary>
+ /// <param name="a"></param>
+ /// <param name="b"></param>
+ /// <returns></returns>
+ public LSL_Float osMax(double a, double b)
+ {
+ CheckThreatLevel(ThreatLevel.None, "osMax");
+ m_host.AddScriptLPS(1);
+
+ return Math.Max(a, b);
+ }
}
}
\ 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 c9403eb..f73a85e 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs
@@ -283,5 +283,21 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces
/// <param name="thing"></param>
/// <returns>1 if thing is a valid UUID, 0 otherwise</returns>
LSL_Integer osIsUUID(string thing);
+
+ /// <summary>
+ /// Wraps to Math.Min()
+ /// </summary>
+ /// <param name="a"></param>
+ /// <param name="b"></param>
+ /// <returns></returns>
+ LSL_Float osMin(double a, double b);
+
+ /// <summary>
+ /// Wraps to Math.max()
+ /// </summary>
+ /// <param name="a"></param>
+ /// <param name="b"></param>
+ /// <returns></returns>
+ LSL_Float osMax(double a, double b);
}
}
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs
index 99995a7..53daa13 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs
@@ -935,5 +935,15 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase
{
return m_OSSL_Functions.osIsUUID(thing);
}
+
+ public LSL_Float osMin(double a, double b)
+ {
+ return m_OSSL_Functions.osMin(a, b);
+ }
+
+ public LSL_Float osMax(double a, double b)
+ {
+ return m_OSSL_Functions.osMax(a, b);
+ }
}
}
--
1.7.11.msysgit.1
|
|