public string llDumpList2String(IScriptInstance script, lsl_list src, string separator) { int len = src.Length; string[] arr = new string[len]; for (int i = 0; i < len; i++) arr[i] = src.Data[i].ToString(); return String.Join(separator, arr); }
public string llList2CSV(IScriptInstance script, lsl_list list) { return list.ToCSV(); }
public lsl_list llGetSubList(IScriptInstance script, lsl_list src, int start, int end) { return src.GetSublist(start, end); }
public int llGetListLength(IScriptInstance script, lsl_list src) { return src.Length; }
public lsl_list llDeleteSubList(IScriptInstance script, lsl_list list, int start, int end) { return list.DeleteSublist(start, end); }
public void llSetPayPrice(IScriptInstance script, int defaultPrice, lsl_list buttons) { if (script.Host is LLPrimitive) { LLPrimitive prim = (LLPrimitive)script.Host; prim.PayPrice = defaultPrice; prim.PayPriceButtons[0] = buttons.Length > 0 ? buttons.GetLSLIntegerItem(0) : lsl_integer.Zero; prim.PayPriceButtons[1] = buttons.Length > 1 ? buttons.GetLSLIntegerItem(1) : lsl_integer.Zero; prim.PayPriceButtons[2] = buttons.Length > 2 ? buttons.GetLSLIntegerItem(2) : lsl_integer.Zero; prim.PayPriceButtons[3] = buttons.Length > 3 ? buttons.GetLSLIntegerItem(3) : lsl_integer.Zero; } else { // TODO: Warning } }
public double llListStatistics(IScriptInstance script, int operation, lsl_list src) { switch (operation) { case LSLScriptBase.LIST_STAT_GEOMETRIC_MEAN: return src.GeometricMean(); case LSLScriptBase.LIST_STAT_HARMONIC_MEAN: return src.HarmonicMean(); case LSLScriptBase.LIST_STAT_MAX: return src.Max(); case LSLScriptBase.LIST_STAT_MEAN: return src.Mean(); case LSLScriptBase.LIST_STAT_MEDIAN: return src.Median(); case LSLScriptBase.LIST_STAT_MIN: return src.Min(); case LSLScriptBase.LIST_STAT_NUM_COUNT: return src.NumericLength(); case LSLScriptBase.LIST_STAT_RANGE: return src.Range(); case LSLScriptBase.LIST_STAT_STD_DEV: return src.StdDev(); case LSLScriptBase.LIST_STAT_SUM: return src.Sum(); case LSLScriptBase.LIST_STAT_SUM_SQUARES: return src.SumSqrs(); default: return 0f; } }
public Vector3 llList2Vector(IScriptInstance script, lsl_list src, int index) { Vector3 ret; if (Vector3.TryParse(src.Data[index].ToString(), out ret)) return ret; else return Vector3.Zero; }
public lsl_list llListRandomize(IScriptInstance script, lsl_list src) { List<object> items = new List<object>(src.Data); object[] objects = new object[src.Data.Length]; for (int i=0; items.Count > 0; i++) { int randomIndex = new Random().Next(items.Count); objects[i] = items[randomIndex]; items.RemoveAt(randomIndex); } return new lsl_list(objects); }
public lsl_list llList2List(IScriptInstance script, lsl_list list, int start, int end) { return list.GetSublist(start, end); }
public string llList2String(IScriptInstance script, lsl_list src, int index) { return src.Data[index].ToString(); }
public string llList2Key(IScriptInstance script, lsl_list list, int index) { return list.Data[index].ToString(); }
public lsl_list GetSublist(int start, int end) { object[] ret; // Take care of neg start or end's // NOTE that either index may still be negative after // adding the length, so we must take additional // measures to protect against this. Note also that // after normalisation the negative indices are no // longer relative to the end of the list. if (start < 0) { start = m_data.Length + start; } if (end < 0) { end = m_data.Length + end; } // The conventional case is start <= end // NOTE that the case of an empty list is // dealt with by the initial test. Start // less than end is taken to be the most // common case. if (start <= end) { // Start sublist beyond length // Also deals with start AND end still negative if (start >= m_data.Length || end < 0) { return new lsl_list(); } // Sublist extends beyond the end of the supplied list if (end >= m_data.Length) { end = m_data.Length - 1; } // Sublist still starts before the beginning of the list if (start < 0) { start = 0; } ret = new object[end - start + 1]; Array.Copy(m_data, start, ret, 0, end - start + 1); return new lsl_list(ret); } // Deal with the segmented case: 0->end + start->EOL else { lsl_list result = null; // If end is negative, then prefix list is empty if (end < 0) { result = new lsl_list(); // If start is still negative, then the whole of // the existing list is returned. This case is // only admitted if end is also still negative. if (start < 0) { return this; } } else { result = GetSublist(0, end); } // If start is outside of list, then just return // the prefix, whatever it is. if (start >= m_data.Length) { return result; } return result + GetSublist(start, Data.Length); } }
public static lsl_list ToDoubleList(lsl_list src) { lsl_list ret = new lsl_list(); double entry; for (int i = 0; i < src.Data.Length - 1; i++) { if (double.TryParse(src.Data[i].ToString(), out entry)) { ret.Add(entry); } } return ret; }
public float llList2Float(IScriptInstance script, lsl_list list, int index) { float ret; if (Single.TryParse(list.Data[index].ToString(), out ret)) return ret; else return 0f; }
public lsl_list llListSort(IScriptInstance script, lsl_list src, int stride, int ascending) { return src.Sort(stride, ascending); }
public int llList2Integer(IScriptInstance script, lsl_list list, int index) { int ret; if (Int32.TryParse(list.Data[index].ToString(), out ret)) return ret; else return 0; }
public lsl_list llGetObjectDetails(IScriptInstance script, string objectID, lsl_list details) { lsl_list ret = new lsl_list(); UUID key; ISceneEntity obj; if (UUID.TryParse(objectID, out key) && script.Host.Scene.TryGetEntity(key, out obj)) { for (int i = 0, len = details.Length; i < len; i++) { int item = details.GetLSLIntegerItem(i); switch (item) { case LSLScriptBase.OBJECT_CREATOR: ret.Add(obj.CreatorID.ToString()); break; case LSLScriptBase.OBJECT_DESC: if (obj is LLPrimitive) ret.Add(((LLPrimitive)obj).Prim.Properties.Description); else ret.Add(String.Empty); break; case LSLScriptBase.OBJECT_GROUP: ret.Add(obj.GroupID.ToString()); break; case LSLScriptBase.OBJECT_NAME: ret.Add(obj.Name); break; case LSLScriptBase.OBJECT_OWNER: ret.Add(obj.OwnerID.ToString()); break; case LSLScriptBase.OBJECT_POS: ret.Add(obj.ScenePosition); // TODO: Verify that this matches LSL break; case LSLScriptBase.OBJECT_ROT: ret.Add(obj.SceneRotation); // TODO: Verify that this matches LSL break; case LSLScriptBase.OBJECT_VELOCITY: if (obj is IPhysical) ret.Add(((IPhysical)obj).Velocity); else ret.Add(Vector3.Zero); break; } } } else { // TODO: Return status of non LLPrimitive objects m_log.Warn("llGetObjectDetails called for non LLPrimitive target in object \"" + script.Host.Name + "\" at " + script.Host.ScenePosition); } return ret; }