mirror of
https://github.com/opensim/opensim.git
synced 2026-07-31 05:45:37 +08:00
-make ZERO_VECTOR and ZERO_ROTATION static readonly properties so they can be
used in scripts
-cast from bool to LSL{Integer,Float,String} so functions such as `integer
isZero(integer x) { return (x == 0); }` work
-progress on issue 1863
This commit is contained in:
@@ -2421,7 +2421,7 @@ namespace OpenSim.Region.ScriptEngine.Common
|
||||
public const int OBJECT_CREATOR = 8;
|
||||
|
||||
// Can not be public const?
|
||||
public vector ZERO_VECTOR = new vector(0.0, 0.0, 0.0);
|
||||
public rotation ZERO_ROTATION = new rotation(0.0, 0, 0.0, 1.0);
|
||||
public static readonly vector ZERO_VECTOR = new vector(0.0, 0.0, 0.0);
|
||||
public static readonly rotation ZERO_ROTATION = new rotation(0.0, 0, 0.0, 1.0);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1186,6 +1186,14 @@ namespace OpenSim.Region.ScriptEngine.Common
|
||||
return new LSLString(f);
|
||||
}
|
||||
|
||||
static public explicit operator LSLString(bool b)
|
||||
{
|
||||
if (b)
|
||||
return new LSLString("1");
|
||||
else
|
||||
return new LSLString("0");
|
||||
}
|
||||
|
||||
public static implicit operator Vector3(LSLString s)
|
||||
{
|
||||
return new Vector3(s.m_string);
|
||||
@@ -1303,6 +1311,14 @@ namespace OpenSim.Region.ScriptEngine.Common
|
||||
return new LSLInteger(f.value);
|
||||
}
|
||||
|
||||
static public implicit operator LSLInteger(bool b)
|
||||
{
|
||||
if (b)
|
||||
return new LSLInteger(1);
|
||||
else
|
||||
return new LSLInteger(0);
|
||||
}
|
||||
|
||||
static public bool operator ==(LSLInteger i1, LSLInteger i2)
|
||||
{
|
||||
bool ret = i1.value == i2.value;
|
||||
@@ -1481,6 +1497,14 @@ namespace OpenSim.Region.ScriptEngine.Common
|
||||
return new LSLFloat(d);
|
||||
}
|
||||
|
||||
static public implicit operator LSLFloat(bool b)
|
||||
{
|
||||
if (b)
|
||||
return new LSLFloat(1.0);
|
||||
else
|
||||
return new LSLFloat(0.0);
|
||||
}
|
||||
|
||||
static public bool operator ==(LSLFloat f1, LSLFloat f2)
|
||||
{
|
||||
return f1.value == f2.value;
|
||||
|
||||
@@ -416,8 +416,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase
|
||||
public const int OBJECT_CREATOR = 8;
|
||||
|
||||
// Can not be public const?
|
||||
public vector ZERO_VECTOR = new vector(0.0, 0.0, 0.0);
|
||||
public rotation ZERO_ROTATION = new rotation(0.0, 0, 0.0, 1.0);
|
||||
public static readonly vector ZERO_VECTOR = new vector(0.0, 0.0, 0.0);
|
||||
public static readonly rotation ZERO_ROTATION = new rotation(0.0, 0, 0.0, 1.0);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1186,6 +1186,14 @@ namespace OpenSim.Region.ScriptEngine.Shared
|
||||
return new LSLString(f);
|
||||
}
|
||||
|
||||
static public explicit operator LSLString(bool b)
|
||||
{
|
||||
if (b)
|
||||
return new LSLString("1");
|
||||
else
|
||||
return new LSLString("0");
|
||||
}
|
||||
|
||||
public static implicit operator Vector3(LSLString s)
|
||||
{
|
||||
return new Vector3(s.m_string);
|
||||
@@ -1303,6 +1311,14 @@ namespace OpenSim.Region.ScriptEngine.Shared
|
||||
return new LSLInteger(f.value);
|
||||
}
|
||||
|
||||
static public implicit operator LSLInteger(bool b)
|
||||
{
|
||||
if (b)
|
||||
return new LSLInteger(1);
|
||||
else
|
||||
return new LSLInteger(0);
|
||||
}
|
||||
|
||||
static public bool operator ==(LSLInteger i1, LSLInteger i2)
|
||||
{
|
||||
bool ret = i1.value == i2.value;
|
||||
@@ -1481,6 +1497,14 @@ namespace OpenSim.Region.ScriptEngine.Shared
|
||||
return new LSLFloat(d);
|
||||
}
|
||||
|
||||
static public implicit operator LSLFloat(bool b)
|
||||
{
|
||||
if (b)
|
||||
return new LSLFloat(1.0);
|
||||
else
|
||||
return new LSLFloat(0.0);
|
||||
}
|
||||
|
||||
static public bool operator ==(LSLFloat f1, LSLFloat f2)
|
||||
{
|
||||
return f1.value == f2.value;
|
||||
|
||||
Reference in New Issue
Block a user