From ad042f1d75fcbadfe4d82b50ae577b86006e5578 Mon Sep 17 00:00:00 2001 From: Tedd Hansen Date: Sat, 15 Sep 2007 15:45:20 +0000 Subject: Implemented llList2CSV, llCSV2List, llListRandomize, llList2Vector, llListFindList, llListInsertList, llDeleteSubList --- .../Compiler/Server_API/LSL_BuiltIn_Commands.cs | 131 +++++++++++++++++++-- 1 file changed, 118 insertions(+), 13 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/Server_API/LSL_BuiltIn_Commands.cs b/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/Server_API/LSL_BuiltIn_Commands.cs index 3404bac..6000193 100644 --- a/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/Server_API/LSL_BuiltIn_Commands.cs +++ b/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/Server_API/LSL_BuiltIn_Commands.cs @@ -234,14 +234,10 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler public void llOffsetTexture(double u, double v, int face) { NotImplemented("llOffsetTexture"); return; } public void llRotateTexture(double rotation, int face) { NotImplemented("llRotateTexture"); return; } - public string llGetTexture(int face) - { - throw new NotImplementedException(cni); return ""; - } + public string llGetTexture(int face) { NotImplemented("llGetTexture"); return ""; } public void llSetPos(LSL_Types.Vector3 pos) { - LLVector3 tmp; if (m_host.ParentID != 0) { m_host.UpdateOffSet(new LLVector3((float)pos.X, (float)pos.Y, (float)pos.Z)); @@ -508,14 +504,101 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler return ""; } - public LSL_Types.Vector3 llList2Vector(List src, int index) { NotImplemented("llList2Vector"); return new LSL_Types.Vector3(); } + public LSL_Types.Vector3 llList2Vector(List src, int index) + { + return new LSL_Types.Vector3(double.Parse(src[index]), double.Parse(src[index + 1]), double.Parse(src[index + 2])); + } public LSL_Types.Quaternion llList2Rot(List src, int index) { NotImplemented("llList2Rot"); return new LSL_Types.Quaternion(); } - public List llList2List(List src, int start, int end) { NotImplemented("llList2List"); return new List(); } - public List llDeleteSubList(List src, int start, int end) { NotImplemented("llDeleteSubList"); return new List(); } + public List llList2List(List src, int start, int end) + { + if (end > start) + { + // Simple straight forward chunk + return src.GetRange(start, end - start); + } + else + { + // Some of the end + some of the beginning + // First chunk + List ret = new List(); + ret.AddRange(src.GetRange(start, src.Count - start)); + ret.AddRange(src.GetRange(0, end)); + return ret; + } + + + + + } + public List llDeleteSubList(List src, int start, int end) + { + List ret = new List(src); + ret.RemoveRange(start, end - start); + return ret; + } public int llGetListEntryType(List src, int index) { NotImplemented("llGetListEntryType"); return 0; } - public string llList2CSV(List src) { NotImplemented("llList2CSV"); return ""; } - public List llCSV2List(string src) { NotImplemented("llCSV2List"); return new List(); } - public List llListRandomize(List src, int stride) { NotImplemented("llListRandomize"); return new List(); } + public string llList2CSV(List src) + { + string ret = ""; + foreach (string s in src) + { + if (s.Length > 0) + ret += ","; + ret += s; + } + return ret; + } + public List llCSV2List(string src) + { + List ret = new List(); + foreach (string s in src.Split(",".ToCharArray())) + { + ret.Add(s); + } + return ret; + } + public List llListRandomize(List src, int stride) + { + int s = stride; + if (s < 1) + s = 1; + + // This is a cowardly way of doing it ;) + // TODO: Instead, randomize and check if random is mod stride or if it can not be, then array.removerange + List> tmp = new List>(); + + // Add chunks to an array + int c = 0; + List chunk = new List(); + foreach (string element in src) + { + c++; + if (c > s) + { + tmp.Add(chunk); + chunk = new List(); + c = 0; + } + chunk.Add(element); + } + + // Decreate array back into a list + int rnd; + List ret = new List(); + while (tmp.Count > 0) + { + rnd = Util.RandomClass.Next(tmp.Count); + foreach (string str in tmp[rnd]) + { + ret.Add(str); + } + tmp.RemoveAt(rnd); + } + + return ret; + + + } public List llList2ListStrided(List src, int start, int end, int stride) { NotImplemented("llList2ListStrided"); return new List(); } public LSL_Types.Vector3 llGetRegionCorner() @@ -523,8 +606,30 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler return new LSL_Types.Vector3(World.RegionInfo.RegionLocX * 256, World.RegionInfo.RegionLocY * 256, 0); } - public List llListInsertList(List dest, List src, int start) { NotImplemented("llListInsertList"); return new List(); } - public int llListFindList(List src, List test) { return 0; } + public List llListInsertList(List dest, List src, int start) + { + + List ret = new List(dest); + //foreach (string s in src.Reverse()) + for (int ci = src.Count - 1; ci > -1; ci--) + { + ret.Insert(start, src[ci]); + } + return ret; + } + public int llListFindList(List src, List test) + { + foreach (string s in test) + { + for (int ci = 0; ci < src.Count; ci++) + { + + if (s == src[ci]) + return ci; + } + } + return -1; + } public string llGetObjectName() { -- cgit v1.1