mirror of
https://github.com/opensim/opensim.git
synced 2026-08-09 02:36:00 +08:00
add from string, from lsl string and from span lsl vector3 and rotation variants
This commit is contained in:
@@ -5562,14 +5562,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
||||
|
||||
object item = src.Data[index];
|
||||
|
||||
//if (item.GetType() == typeof(LSL_Vector))
|
||||
// return (LSL_Vector)item;
|
||||
|
||||
if(item is LSL_Vector vec)
|
||||
return vec;
|
||||
|
||||
if (item is LSL_String lsv)
|
||||
return new LSL_Vector(lsv.m_string);
|
||||
return new LSL_Vector(lsv);
|
||||
if (item is string sv) // xengine sees string
|
||||
return new LSL_Vector(sv);
|
||||
|
||||
@@ -5582,24 +5579,18 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
||||
index = src.Length + index;
|
||||
|
||||
if (index >= src.Length || index < 0)
|
||||
return new LSL_Rotation(0, 0, 0, 1);
|
||||
return LSL_Rotation.Identity;
|
||||
|
||||
object item = src.Data[index];
|
||||
|
||||
// SL spits always out ZERO_ROTATION for anything other than
|
||||
// strings or vectors. Although keys always return ZERO_ROTATION,
|
||||
// it is currently difficult to make the distinction between
|
||||
// a string, a key as string and a string that by coincidence
|
||||
// is a string, so we're going to leave that up to the
|
||||
// LSL_Rotation constructor.
|
||||
|
||||
if (item.GetType() == typeof(LSL_Rotation))
|
||||
return (LSL_Rotation)item;
|
||||
if (item is LSL_Rotation rot)
|
||||
return rot;
|
||||
if (item is LSL_String lls)
|
||||
return new LSL_Rotation(lls);
|
||||
if (item is string ls) // xengine sees string)
|
||||
return new LSL_Rotation(ls);
|
||||
|
||||
if (item is LSL_String || item is string) // xengine sees string)
|
||||
return new LSL_Rotation(src.Data[index].ToString());
|
||||
|
||||
return new LSL_Rotation(0, 0, 0, 1);
|
||||
return LSL_Rotation.Identity;
|
||||
}
|
||||
|
||||
public LSL_List llList2List(LSL_List src, int start, int end)
|
||||
@@ -5676,10 +5667,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
||||
int parens = 0;
|
||||
int start = 0;
|
||||
int length = 0;
|
||||
|
||||
for (int i = 0; i < src.Length; i++)
|
||||
|
||||
ReadOnlySpan<char> s = src.AsSpan();
|
||||
for (int i = 0; i < s.Length; i++)
|
||||
{
|
||||
switch (src[i])
|
||||
switch (s[i])
|
||||
{
|
||||
case '<':
|
||||
parens++;
|
||||
|
||||
Reference in New Issue
Block a user