public int tsuccirEvenlyDistributeChildPrimsInOtherObject(UUID host, UUID script, string otherObject, object[] argsObj) { SceneObjectPart hostPart = m_scene.GetSceneObjectPart(host); hostPart.AddScriptLPS(1); LSL_List args = new LSL_List(); args.Data = argsObj; LSL_Vector size; LSL_Vector point; LSL_Rotation rot; LSL_Vector distribution; LSL_Vector margin; try { size = args.GetVector3Item(0); point = args.GetVector3Item(1); rot = args.GetQuaternionItem(2); distribution = args.GetVector3Item(3); margin = args.GetVector3Item(4); } catch (Exception e) { ScriptError(hostPart, e.Message); return 0; } UUID otherObjectKey; if (!UUID.TryParse(otherObject, out otherObjectKey)) { ScriptError(hostPart, "Other object key is not a valid UUID"); return 0; } SceneObjectPart other = hostPart.ParentGroup.Scene.GetSceneObjectPart(otherObjectKey); if (other == null) { ScriptError(hostPart, "Other object could not be found"); return 0; } return EvenlyDistributeChildPrims(other.ParentGroup, size, point, rot, distribution, margin) ? 1 : 0; }
private RegionLightShareData getWindlightProfileFromRules(LSL_List rules) { RegionLightShareData wl = (RegionLightShareData)m_host.ParentGroup.Scene.RegionInfo.WindlightSettings.Clone(); LSL_List values = new LSL_List(); int idx = 0; while (idx < rules.Length) { uint rule = (uint)rules.GetLSLIntegerItem(idx); LSL_Types.Quaternion iQ; LSL_Types.Vector3 iV; switch (rule) { case (int)ScriptBaseClass.WL_SUN_MOON_POSITION: idx++; wl.sunMoonPosition = (float)rules.GetLSLFloatItem(idx); break; case (int)ScriptBaseClass.WL_AMBIENT: idx++; iQ = rules.GetQuaternionItem(idx); wl.ambient = new Vector4((float)iQ.x, (float)iQ.y, (float)iQ.z, (float)iQ.s); break; case (int)ScriptBaseClass.WL_BIG_WAVE_DIRECTION: idx++; iV = rules.GetVector3Item(idx); wl.bigWaveDirection = new Vector2((float)iV.x, (float)iV.y); break; case (int)ScriptBaseClass.WL_BLUE_DENSITY: idx++; iQ = rules.GetQuaternionItem(idx); wl.blueDensity = new Vector4((float)iQ.x, (float)iQ.y, (float)iQ.z, (float)iQ.s); break; case (int)ScriptBaseClass.WL_BLUR_MULTIPLIER: idx++; wl.blurMultiplier = (float)rules.GetLSLFloatItem(idx); break; case (int)ScriptBaseClass.WL_CLOUD_COLOR: idx++; iQ = rules.GetQuaternionItem(idx); wl.cloudColor = new Vector4((float)iQ.x, (float)iQ.y, (float)iQ.z, (float)iQ.s); break; case (int)ScriptBaseClass.WL_CLOUD_COVERAGE: idx++; wl.cloudCoverage = (float)rules.GetLSLFloatItem(idx); break; case (int)ScriptBaseClass.WL_CLOUD_DETAIL_XY_DENSITY: idx++; iV = rules.GetVector3Item(idx); wl.cloudDetailXYDensity = new Vector3((float)iV.x, (float)iV.y, (float)iV.z); break; case (int)ScriptBaseClass.WL_CLOUD_SCALE: idx++; wl.cloudScale = (float)rules.GetLSLFloatItem(idx); break; case (int)ScriptBaseClass.WL_CLOUD_SCROLL_X: idx++; wl.cloudScrollX = (float)rules.GetLSLFloatItem(idx); break; case (int)ScriptBaseClass.WL_CLOUD_SCROLL_X_LOCK: idx++; wl.cloudScrollXLock = rules.GetLSLIntegerItem(idx).value == 1 ? true : false; break; case (int)ScriptBaseClass.WL_CLOUD_SCROLL_Y: idx++; wl.cloudScrollY = (float)rules.GetLSLFloatItem(idx); break; case (int)ScriptBaseClass.WL_CLOUD_SCROLL_Y_LOCK: idx++; wl.cloudScrollYLock = rules.GetLSLIntegerItem(idx).value == 1 ? true : false; break; case (int)ScriptBaseClass.WL_CLOUD_XY_DENSITY: idx++; iV = rules.GetVector3Item(idx); wl.cloudXYDensity = new Vector3((float)iV.x, (float)iV.y, (float)iV.z); break; case (int)ScriptBaseClass.WL_DENSITY_MULTIPLIER: idx++; wl.densityMultiplier = (float)rules.GetLSLFloatItem(idx); break; case (int)ScriptBaseClass.WL_DISTANCE_MULTIPLIER: idx++; wl.distanceMultiplier = (float)rules.GetLSLFloatItem(idx); break; case (int)ScriptBaseClass.WL_DRAW_CLASSIC_CLOUDS: idx++; wl.drawClassicClouds = rules.GetLSLIntegerItem(idx).value == 1 ? true : false; break; case (int)ScriptBaseClass.WL_EAST_ANGLE: idx++; wl.eastAngle = (float)rules.GetLSLFloatItem(idx); break; case (int)ScriptBaseClass.WL_FRESNEL_OFFSET: idx++; wl.fresnelOffset = (float)rules.GetLSLFloatItem(idx); break; case (int)ScriptBaseClass.WL_FRESNEL_SCALE: idx++; wl.fresnelScale = (float)rules.GetLSLFloatItem(idx); break; case (int)ScriptBaseClass.WL_HAZE_DENSITY: idx++; wl.hazeDensity = (float)rules.GetLSLFloatItem(idx); break; case (int)ScriptBaseClass.WL_HAZE_HORIZON: idx++; wl.hazeHorizon = (float)rules.GetLSLFloatItem(idx); break; case (int)ScriptBaseClass.WL_HORIZON: idx++; iQ = rules.GetQuaternionItem(idx); wl.horizon = new Vector4((float)iQ.x, (float)iQ.y, (float)iQ.z, (float)iQ.s); break; case (int)ScriptBaseClass.WL_LITTLE_WAVE_DIRECTION: idx++; iV = rules.GetVector3Item(idx); wl.littleWaveDirection = new Vector2((float)iV.x, (float)iV.y); break; case (int)ScriptBaseClass.WL_MAX_ALTITUDE: idx++; wl.maxAltitude = (ushort)rules.GetLSLIntegerItem(idx).value; break; case (int)ScriptBaseClass.WL_NORMAL_MAP_TEXTURE: idx++; wl.normalMapTexture = new UUID(rules.GetLSLStringItem(idx).m_string); break; case (int)ScriptBaseClass.WL_REFLECTION_WAVELET_SCALE: idx++; iV = rules.GetVector3Item(idx); wl.reflectionWaveletScale = new Vector3((float)iV.x, (float)iV.y, (float)iV.z); break; case (int)ScriptBaseClass.WL_REFRACT_SCALE_ABOVE: idx++; wl.refractScaleAbove = (float)rules.GetLSLFloatItem(idx); break; case (int)ScriptBaseClass.WL_REFRACT_SCALE_BELOW: idx++; wl.refractScaleBelow = (float)rules.GetLSLFloatItem(idx); break; case (int)ScriptBaseClass.WL_SCENE_GAMMA: idx++; wl.sceneGamma = (float)rules.GetLSLFloatItem(idx); break; case (int)ScriptBaseClass.WL_STAR_BRIGHTNESS: idx++; wl.starBrightness = (float)rules.GetLSLFloatItem(idx); break; case (int)ScriptBaseClass.WL_SUN_GLOW_FOCUS: idx++; wl.sunGlowFocus = (float)rules.GetLSLFloatItem(idx); break; case (int)ScriptBaseClass.WL_SUN_GLOW_SIZE: idx++; wl.sunGlowSize = (float)rules.GetLSLFloatItem(idx); break; case (int)ScriptBaseClass.WL_SUN_MOON_COLOR: idx++; iQ = rules.GetQuaternionItem(idx); wl.sunMoonColor = new Vector4((float)iQ.x, (float)iQ.y, (float)iQ.z, (float)iQ.s); break; case (int)ScriptBaseClass.WL_UNDERWATER_FOG_MODIFIER: idx++; wl.underwaterFogModifier = (float)rules.GetLSLFloatItem(idx); break; case (int)ScriptBaseClass.WL_WATER_COLOR: idx++; iV = rules.GetVector3Item(idx); wl.waterColor = new Vector3((float)iV.x, (float)iV.y, (float)iV.z); break; case (int)ScriptBaseClass.WL_WATER_FOG_DENSITY_EXPONENT: idx++; wl.waterFogDensityExponent = (float)rules.GetLSLFloatItem(idx); break; } idx++; } return(wl); }
protected void SetPrimParams(SceneObjectPart part, LSL_List rules) { int idx = 0; bool positionChanged = false; LSL_Vector currentPosition = GetPartLocalPos(part); try { while (idx < rules.Length) { int code = rules.GetLSLIntegerItem(idx++); int remain = rules.Length - idx; int face; LSL_Vector v; switch (code) { case (int)ScriptBaseClass.PRIM_POSITION: case (int)ScriptBaseClass.PRIM_POS_LOCAL: if (remain < 1) return; v=rules.GetVector3Item(idx++); positionChanged = true; currentPosition = GetSetPosTarget(part, v, currentPosition); break; case (int)ScriptBaseClass.PRIM_SIZE: if (remain < 1) return; v=rules.GetVector3Item(idx++); SetScale(part, v); break; case (int)ScriptBaseClass.PRIM_ROTATION: if (remain < 1) return; LSL_Rotation q = rules.GetQuaternionItem(idx++); // try to let this work as in SL... if (part.ParentID == 0) { // special case: If we are root, rotate complete SOG to new rotation SetRot(part, Rot2Quaternion(q)); } else { // we are a child. The rotation values will be set to the one of root modified by rot, as in SL. Don't ask. SceneObjectPart rootPart = part.ParentGroup.RootPart; SetRot(part, rootPart.RotationOffset * Rot2Quaternion(q)); } break; case (int)ScriptBaseClass.PRIM_TYPE: if (remain < 3) return; code = (int)rules.GetLSLIntegerItem(idx++); remain = rules.Length - idx; float hollow; LSL_Vector twist; LSL_Vector taper_b; LSL_Vector topshear; float revolutions; float radiusoffset; float skew; LSL_Vector holesize; LSL_Vector profilecut; switch (code) { case (int)ScriptBaseClass.PRIM_TYPE_BOX: if (remain < 6) return; face = (int)rules.GetLSLIntegerItem(idx++); v = rules.GetVector3Item(idx++); // cut hollow = (float)rules.GetLSLFloatItem(idx++); twist = rules.GetVector3Item(idx++); taper_b = rules.GetVector3Item(idx++); topshear = rules.GetVector3Item(idx++); SetPrimitiveShapeParams(part, face, v, hollow, twist, taper_b, topshear, (byte)ProfileShape.Square, (byte)Extrusion.Straight); break; case (int)ScriptBaseClass.PRIM_TYPE_CYLINDER: if (remain < 6) return; face = (int)rules.GetLSLIntegerItem(idx++); // holeshape v = rules.GetVector3Item(idx++); // cut hollow = (float)rules.GetLSLFloatItem(idx++); twist = rules.GetVector3Item(idx++); taper_b = rules.GetVector3Item(idx++); topshear = rules.GetVector3Item(idx++); SetPrimitiveShapeParams(part, face, v, hollow, twist, taper_b, topshear, (byte)ProfileShape.Circle, (byte)Extrusion.Straight); break; case (int)ScriptBaseClass.PRIM_TYPE_PRISM: if (remain < 6) return; face = (int)rules.GetLSLIntegerItem(idx++); // holeshape v = rules.GetVector3Item(idx++); //cut hollow = (float)rules.GetLSLFloatItem(idx++); twist = rules.GetVector3Item(idx++); taper_b = rules.GetVector3Item(idx++); topshear = rules.GetVector3Item(idx++); SetPrimitiveShapeParams(part, face, v, hollow, twist, taper_b, topshear, (byte)ProfileShape.EquilateralTriangle, (byte)Extrusion.Straight); break; case (int)ScriptBaseClass.PRIM_TYPE_SPHERE: if (remain < 5) return; face = (int)rules.GetLSLIntegerItem(idx++); // holeshape v = rules.GetVector3Item(idx++); // cut hollow = (float)rules.GetLSLFloatItem(idx++); twist = rules.GetVector3Item(idx++); taper_b = rules.GetVector3Item(idx++); // dimple SetPrimitiveShapeParams(part, face, v, hollow, twist, taper_b, (byte)ProfileShape.HalfCircle, (byte)Extrusion.Curve1); break; case (int)ScriptBaseClass.PRIM_TYPE_TORUS: if (remain < 11) return; face = (int)rules.GetLSLIntegerItem(idx++); // holeshape v = rules.GetVector3Item(idx++); //cut hollow = (float)rules.GetLSLFloatItem(idx++); twist = rules.GetVector3Item(idx++); holesize = rules.GetVector3Item(idx++); topshear = rules.GetVector3Item(idx++); profilecut = rules.GetVector3Item(idx++); taper_b = rules.GetVector3Item(idx++); // taper_a revolutions = (float)rules.GetLSLFloatItem(idx++); radiusoffset = (float)rules.GetLSLFloatItem(idx++); skew = (float)rules.GetLSLFloatItem(idx++); SetPrimitiveShapeParams(part, face, v, hollow, twist, holesize, topshear, profilecut, taper_b, revolutions, radiusoffset, skew, (byte)ProfileShape.Circle, (byte)Extrusion.Curve1); break; case (int)ScriptBaseClass.PRIM_TYPE_TUBE: if (remain < 11) return; face = (int)rules.GetLSLIntegerItem(idx++); // holeshape v = rules.GetVector3Item(idx++); //cut hollow = (float)rules.GetLSLFloatItem(idx++); twist = rules.GetVector3Item(idx++); holesize = rules.GetVector3Item(idx++); topshear = rules.GetVector3Item(idx++); profilecut = rules.GetVector3Item(idx++); taper_b = rules.GetVector3Item(idx++); // taper_a revolutions = (float)rules.GetLSLFloatItem(idx++); radiusoffset = (float)rules.GetLSLFloatItem(idx++); skew = (float)rules.GetLSLFloatItem(idx++); SetPrimitiveShapeParams(part, face, v, hollow, twist, holesize, topshear, profilecut, taper_b, revolutions, radiusoffset, skew, (byte)ProfileShape.Square, (byte)Extrusion.Curve1); break; case (int)ScriptBaseClass.PRIM_TYPE_RING: if (remain < 11) return; face = (int)rules.GetLSLIntegerItem(idx++); // holeshape v = rules.GetVector3Item(idx++); //cut hollow = (float)rules.GetLSLFloatItem(idx++); twist = rules.GetVector3Item(idx++); holesize = rules.GetVector3Item(idx++); topshear = rules.GetVector3Item(idx++); profilecut = rules.GetVector3Item(idx++); taper_b = rules.GetVector3Item(idx++); // taper_a revolutions = (float)rules.GetLSLFloatItem(idx++); radiusoffset = (float)rules.GetLSLFloatItem(idx++); skew = (float)rules.GetLSLFloatItem(idx++); SetPrimitiveShapeParams(part, face, v, hollow, twist, holesize, topshear, profilecut, taper_b, revolutions, radiusoffset, skew, (byte)ProfileShape.EquilateralTriangle, (byte)Extrusion.Curve1); break; case (int)ScriptBaseClass.PRIM_TYPE_SCULPT: if (remain < 2) return; string map = rules.Data[idx++].ToString(); face = (int)rules.GetLSLIntegerItem(idx++); // type SetPrimitiveShapeParams(part, map, face, (byte)Extrusion.Curve1); break; } break; case (int)ScriptBaseClass.PRIM_TEXTURE: if (remain < 5) return; face=(int)rules.GetLSLIntegerItem(idx++); string tex=rules.Data[idx++].ToString(); LSL_Vector repeats=rules.GetVector3Item(idx++); LSL_Vector offsets=rules.GetVector3Item(idx++); double rotation=(double)rules.GetLSLFloatItem(idx++); SetTexture(part, tex, face); ScaleTexture(part, repeats.x, repeats.y, face); OffsetTexture(part, offsets.x, offsets.y, face); RotateTexture(part, rotation, face); break; case (int)ScriptBaseClass.PRIM_COLOR: if (remain < 3) return; face=(int)rules.GetLSLIntegerItem(idx++); LSL_Vector color=rules.GetVector3Item(idx++); double alpha=(double)rules.GetLSLFloatItem(idx++); part.SetFaceColor(new Vector3((float)color.x, (float)color.y, (float)color.z), face); SetAlpha(part, alpha, face); break; case (int)ScriptBaseClass.PRIM_FLEXIBLE: if (remain < 7) return; bool flexi = rules.GetLSLIntegerItem(idx++); int softness = rules.GetLSLIntegerItem(idx++); float gravity = (float)rules.GetLSLFloatItem(idx++); float friction = (float)rules.GetLSLFloatItem(idx++); float wind = (float)rules.GetLSLFloatItem(idx++); float tension = (float)rules.GetLSLFloatItem(idx++); LSL_Vector force = rules.GetVector3Item(idx++); SetFlexi(part, flexi, softness, gravity, friction, wind, tension, force); break; case (int)ScriptBaseClass.PRIM_POINT_LIGHT: if (remain < 5) return; bool light = rules.GetLSLIntegerItem(idx++); LSL_Vector lightcolor = rules.GetVector3Item(idx++); float intensity = (float)rules.GetLSLFloatItem(idx++); float radius = (float)rules.GetLSLFloatItem(idx++); float falloff = (float)rules.GetLSLFloatItem(idx++); SetPointLight(part, light, lightcolor, intensity, radius, falloff); break; case (int)ScriptBaseClass.PRIM_GLOW: if (remain < 2) return; face = rules.GetLSLIntegerItem(idx++); float glow = (float)rules.GetLSLFloatItem(idx++); SetGlow(part, face, glow); break; case (int)ScriptBaseClass.PRIM_BUMP_SHINY: if (remain < 3) return; face = (int)rules.GetLSLIntegerItem(idx++); int shiny = (int)rules.GetLSLIntegerItem(idx++); Bumpiness bump = (Bumpiness)(int)rules.GetLSLIntegerItem(idx++); SetShiny(part, face, shiny, bump); break; case (int)ScriptBaseClass.PRIM_FULLBRIGHT: if (remain < 2) return; face = rules.GetLSLIntegerItem(idx++); bool st = rules.GetLSLIntegerItem(idx++); SetFullBright(part, face , st); break; case (int)ScriptBaseClass.PRIM_MATERIAL: if (remain < 1) return; int mat = rules.GetLSLIntegerItem(idx++); if (mat < 0 || mat > 7) return; part.Material = Convert.ToByte(mat); break; case (int)ScriptBaseClass.PRIM_PHANTOM: if (remain < 1) return; string ph = rules.Data[idx++].ToString(); m_host.ParentGroup.ScriptSetPhantomStatus(ph.Equals("1")); break; case (int)ScriptBaseClass.PRIM_PHYSICS: if (remain < 1) return; string phy = rules.Data[idx++].ToString(); bool physics; if (phy.Equals("1")) physics = true; else physics = false; part.ScriptSetPhysicsStatus(physics); break; case (int)ScriptBaseClass.PRIM_TEMP_ON_REZ: if (remain < 1) return; string temp = rules.Data[idx++].ToString(); m_host.ParentGroup.ScriptSetTemporaryStatus(temp.Equals("1")); break; case (int)ScriptBaseClass.PRIM_TEXGEN: if (remain < 2) return; //face,type face = rules.GetLSLIntegerItem(idx++); int style = rules.GetLSLIntegerItem(idx++); SetTexGen(part, face, style); break; case (int)ScriptBaseClass.PRIM_TEXT: if (remain < 3) return; string primText = rules.GetLSLStringItem(idx++); LSL_Vector primTextColor = rules.GetVector3Item(idx++); LSL_Float primTextAlpha = rules.GetLSLFloatItem(idx++); Vector3 av3 = new Vector3(Util.Clip((float)primTextColor.x, 0.0f, 1.0f), Util.Clip((float)primTextColor.y, 0.0f, 1.0f), Util.Clip((float)primTextColor.z, 0.0f, 1.0f)); part.SetText(primText, av3, Util.Clip((float)primTextAlpha, 0.0f, 1.0f)); break; case (int)ScriptBaseClass.PRIM_NAME: if (remain < 1) return; string primName = rules.GetLSLStringItem(idx++); part.Name = primName; break; case (int)ScriptBaseClass.PRIM_DESC: if (remain < 1) return; string primDesc = rules.GetLSLStringItem(idx++); part.Description = primDesc; break; case (int)ScriptBaseClass.PRIM_ROT_LOCAL: if (remain < 1) return; LSL_Rotation lr = rules.GetQuaternionItem(idx++); SetRot(part, Rot2Quaternion(lr)); break; case (int)ScriptBaseClass.PRIM_OMEGA: if (remain < 3) return; LSL_Vector axis = rules.GetVector3Item(idx++); LSL_Float spinrate = rules.GetLSLFloatItem(idx++); LSL_Float gain = rules.GetLSLFloatItem(idx++); TargetOmega(part, axis, (double)spinrate, (double)gain); break; case (int)ScriptBaseClass.PRIM_LINK_TARGET: if (remain < 3) // setting to 3 on the basis that parsing any usage of PRIM_LINK_TARGET that has nothing following it is pointless. return; LSL_Integer new_linknumber = rules.GetLSLIntegerItem(idx++); LSL_List new_rules = rules.GetSublist(idx, -1); setLinkPrimParams((int)new_linknumber, new_rules); return; } } } finally { if (positionChanged) { if (part.ParentGroup.RootPart == part) { SceneObjectGroup parent = part.ParentGroup; parent.UpdateGroupPosition(new Vector3((float)currentPosition.x, (float)currentPosition.y, (float)currentPosition.z)); } else { part.OffsetPosition = new Vector3((float)currentPosition.x, (float)currentPosition.y, (float)currentPosition.z); SceneObjectGroup parent = part.ParentGroup; parent.HasGroupChanged = true; parent.ScheduleGroupForTerseUpdate(); } } } }
public int tsuccirEvenlyDistributeChildPrims(UUID host, UUID script, object[] argsObj) { SceneObjectPart hostPart = m_scene.GetSceneObjectPart(host); hostPart.AddScriptLPS(1); LSL_List args = new LSL_List(); args.Data = argsObj; LSL_Vector size = args.GetVector3Item(0); LSL_Vector point = args.GetVector3Item(1); LSL_Rotation rot = args.GetQuaternionItem(2); LSL_Vector distribution = args.GetVector3Item(3); LSL_Vector margin = args.GetVector3Item(4); return EvenlyDistributeChildPrims(hostPart.ParentGroup, size, point, rot, distribution, margin) ? 1 : 0; }
protected LSL_List SetAgentParams(ScenePresence sp, LSL_List rules, string originFunc, ref uint rulesParsed) { int idx = 0; int idxStart = 0; try { while (idx < rules.Length) { ++rulesParsed; int code = rules.GetLSLIntegerItem(idx++); int remain = rules.Length - idx; idxStart = idx; switch (code) { case (int)ScriptBaseClass.PRIM_POSITION: case (int)ScriptBaseClass.PRIM_POS_LOCAL: if (remain < 1) return null; sp.OffsetPosition = rules.GetVector3Item(idx++); break; case (int)ScriptBaseClass.PRIM_ROTATION: if (remain < 1) return null; Quaternion inRot = rules.GetQuaternionItem(idx++); SceneObjectPart parentPart = sp.ParentPart; if (parentPart != null) sp.Rotation = m_host.GetWorldRotation() * inRot; break; case (int)ScriptBaseClass.PRIM_ROT_LOCAL: if (remain < 1) return null; sp.Rotation = rules.GetQuaternionItem(idx++); break; } } } catch (InvalidCastException e) { Error( originFunc, string.Format("Error running rule #{0}: arg #{1} - ", rulesParsed, idx - idxStart) + e.Message); } return null; }
protected void SetPrimParams(SceneObjectPart part, LSL_List rules) { int idx = 0; while (idx < rules.Length) { int code = rules.GetLSLIntegerItem(idx++); int remain = rules.Length - idx; int face; LSL_Vector v; switch (code) { case (int)ScriptBaseClass.PRIM_POSITION: if (remain < 1) return; v=rules.GetVector3Item(idx++); SetPos(part, v); break; case (int)ScriptBaseClass.PRIM_SIZE: if (remain < 1) return; v=rules.GetVector3Item(idx++); SetScale(part, v); break; case (int)ScriptBaseClass.PRIM_ROTATION: if (remain < 1) return; LSL_Rotation q = rules.GetQuaternionItem(idx++); // try to let this work as in SL... if (part.ParentID == 0) { // special case: If we are root, rotate complete SOG to new rotation SetRot(part, Rot2Quaternion(q)); } else { // we are a child. The rotation values will be set to the one of root modified by rot, as in SL. Don't ask. SceneObjectGroup group = part.ParentGroup; if (group != null) // a bit paranoid, maybe { SceneObjectPart rootPart = group.RootPart; if (rootPart != null) // again, better safe than sorry { SetRot(part, rootPart.RotationOffset * Rot2Quaternion(q)); } } } break; case (int)ScriptBaseClass.PRIM_TYPE: if (remain < 3) return; code = (int)rules.GetLSLIntegerItem(idx++); remain = rules.Length - idx; float hollow; LSL_Vector twist; LSL_Vector taper_b; LSL_Vector topshear; float revolutions; float radiusoffset; float skew; LSL_Vector holesize; LSL_Vector profilecut; switch (code) { case (int)ScriptBaseClass.PRIM_TYPE_BOX: if (remain < 6) return; face = (int)rules.GetLSLIntegerItem(idx++); v = rules.GetVector3Item(idx++); // cut hollow = (float)rules.GetLSLFloatItem(idx++); twist = rules.GetVector3Item(idx++); taper_b = rules.GetVector3Item(idx++); topshear = rules.GetVector3Item(idx++); part.Shape.PathCurve = (byte)Extrusion.Straight; SetPrimitiveShapeParams(part, face, v, hollow, twist, taper_b, topshear, 1); break; case (int)ScriptBaseClass.PRIM_TYPE_CYLINDER: if (remain < 6) return; face = (int)rules.GetLSLIntegerItem(idx++); // holeshape v = rules.GetVector3Item(idx++); // cut hollow = (float)rules.GetLSLFloatItem(idx++); twist = rules.GetVector3Item(idx++); taper_b = rules.GetVector3Item(idx++); topshear = rules.GetVector3Item(idx++); part.Shape.ProfileShape = ProfileShape.Circle; part.Shape.PathCurve = (byte)Extrusion.Straight; SetPrimitiveShapeParams(part, face, v, hollow, twist, taper_b, topshear, 0); break; case (int)ScriptBaseClass.PRIM_TYPE_PRISM: if (remain < 6) return; face = (int)rules.GetLSLIntegerItem(idx++); // holeshape v = rules.GetVector3Item(idx++); //cut hollow = (float)rules.GetLSLFloatItem(idx++); twist = rules.GetVector3Item(idx++); taper_b = rules.GetVector3Item(idx++); topshear = rules.GetVector3Item(idx++); part.Shape.PathCurve = (byte)Extrusion.Straight; SetPrimitiveShapeParams(part, face, v, hollow, twist, taper_b, topshear, 3); break; case (int)ScriptBaseClass.PRIM_TYPE_SPHERE: if (remain < 5) return; face = (int)rules.GetLSLIntegerItem(idx++); // holeshape v = rules.GetVector3Item(idx++); // cut hollow = (float)rules.GetLSLFloatItem(idx++); twist = rules.GetVector3Item(idx++); taper_b = rules.GetVector3Item(idx++); // dimple part.Shape.PathCurve = (byte)Extrusion.Curve1; SetPrimitiveShapeParams(part, face, v, hollow, twist, taper_b, 5); break; case (int)ScriptBaseClass.PRIM_TYPE_TORUS: if (remain < 11) return; face = (int)rules.GetLSLIntegerItem(idx++); // holeshape v = rules.GetVector3Item(idx++); //cut hollow = (float)rules.GetLSLFloatItem(idx++); twist = rules.GetVector3Item(idx++); holesize = rules.GetVector3Item(idx++); topshear = rules.GetVector3Item(idx++); profilecut = rules.GetVector3Item(idx++); taper_b = rules.GetVector3Item(idx++); // taper_a revolutions = (float)rules.GetLSLFloatItem(idx++); radiusoffset = (float)rules.GetLSLFloatItem(idx++); skew = (float)rules.GetLSLFloatItem(idx++); part.Shape.PathCurve = (byte)Extrusion.Curve1; SetPrimitiveShapeParams(part, face, v, hollow, twist, holesize, topshear, profilecut, taper_b, revolutions, radiusoffset, skew, 0); break; case (int)ScriptBaseClass.PRIM_TYPE_TUBE: if (remain < 11) return; face = (int)rules.GetLSLIntegerItem(idx++); // holeshape v = rules.GetVector3Item(idx++); //cut hollow = (float)rules.GetLSLFloatItem(idx++); twist = rules.GetVector3Item(idx++); holesize = rules.GetVector3Item(idx++); topshear = rules.GetVector3Item(idx++); profilecut = rules.GetVector3Item(idx++); taper_b = rules.GetVector3Item(idx++); // taper_a revolutions = (float)rules.GetLSLFloatItem(idx++); radiusoffset = (float)rules.GetLSLFloatItem(idx++); skew = (float)rules.GetLSLFloatItem(idx++); part.Shape.PathCurve = (byte)Extrusion.Curve1; SetPrimitiveShapeParams(part, face, v, hollow, twist, holesize, topshear, profilecut, taper_b, revolutions, radiusoffset, skew, 1); break; case (int)ScriptBaseClass.PRIM_TYPE_RING: if (remain < 11) return; face = (int)rules.GetLSLIntegerItem(idx++); // holeshape v = rules.GetVector3Item(idx++); //cut hollow = (float)rules.GetLSLFloatItem(idx++); twist = rules.GetVector3Item(idx++); holesize = rules.GetVector3Item(idx++); topshear = rules.GetVector3Item(idx++); profilecut = rules.GetVector3Item(idx++); taper_b = rules.GetVector3Item(idx++); // taper_a revolutions = (float)rules.GetLSLFloatItem(idx++); radiusoffset = (float)rules.GetLSLFloatItem(idx++); skew = (float)rules.GetLSLFloatItem(idx++); part.Shape.PathCurve = (byte)Extrusion.Curve1; SetPrimitiveShapeParams(part, face, v, hollow, twist, holesize, topshear, profilecut, taper_b, revolutions, radiusoffset, skew, 3); break; case (int)ScriptBaseClass.PRIM_TYPE_SCULPT: if (remain < 2) return; string map = rules.Data[idx++].ToString(); face = (int)rules.GetLSLIntegerItem(idx++); // type part.Shape.PathCurve = (byte)Extrusion.Curve1; SetPrimitiveShapeParams(part, map, face); break; } break; case (int)ScriptBaseClass.PRIM_TEXTURE: if (remain < 5) return; face=(int)rules.GetLSLIntegerItem(idx++); string tex=rules.Data[idx++].ToString(); LSL_Vector repeats=rules.GetVector3Item(idx++); LSL_Vector offsets=rules.GetVector3Item(idx++); double rotation=(double)rules.GetLSLFloatItem(idx++); SetTexture(part, tex, face); ScaleTexture(part, repeats.x, repeats.y, face); OffsetTexture(part, offsets.x, offsets.y, face); RotateTexture(part, rotation, face); break; case (int)ScriptBaseClass.PRIM_COLOR: if (remain < 3) return; face=(int)rules.GetLSLIntegerItem(idx++); LSL_Vector color=rules.GetVector3Item(idx++); double alpha=(double)rules.GetLSLFloatItem(idx++); part.SetFaceColor(new Vector3((float)color.x, (float)color.y, (float)color.z), face); SetAlpha(part, alpha, face); break; case (int)ScriptBaseClass.PRIM_FLEXIBLE: if (remain < 7) return; bool flexi = rules.GetLSLIntegerItem(idx++); int softness = rules.GetLSLIntegerItem(idx++); float gravity = (float)rules.GetLSLFloatItem(idx++); float friction = (float)rules.GetLSLFloatItem(idx++); float wind = (float)rules.GetLSLFloatItem(idx++); float tension = (float)rules.GetLSLFloatItem(idx++); LSL_Vector force = rules.GetVector3Item(idx++); SetFlexi(part, flexi, softness, gravity, friction, wind, tension, force); break; case (int)ScriptBaseClass.PRIM_POINT_LIGHT: if (remain < 5) return; bool light = rules.GetLSLIntegerItem(idx++); LSL_Vector lightcolor = rules.GetVector3Item(idx++); float intensity = (float)rules.GetLSLFloatItem(idx++); float radius = (float)rules.GetLSLFloatItem(idx++); float falloff = (float)rules.GetLSLFloatItem(idx++); SetPointLight(part, light, lightcolor, intensity, radius, falloff); break; case (int)ScriptBaseClass.PRIM_GLOW: if (remain < 2) return; face = rules.GetLSLIntegerItem(idx++); float glow = (float)rules.GetLSLFloatItem(idx++); SetGlow(part, face, glow); break; case (int)ScriptBaseClass.PRIM_BUMP_SHINY: if (remain < 3) return; face = (int)rules.GetLSLIntegerItem(idx++); int shiny = (int)rules.GetLSLIntegerItem(idx++); Bumpiness bump = (Bumpiness)Convert.ToByte((int)rules.GetLSLIntegerItem(idx++)); SetShiny(part, face, shiny, bump); break; case (int)ScriptBaseClass.PRIM_FULLBRIGHT: if (remain < 2) return; face = rules.GetLSLIntegerItem(idx++); bool st = rules.GetLSLIntegerItem(idx++); SetFullBright(part, face , st); break; case (int)ScriptBaseClass.PRIM_MATERIAL: if (remain < 1) return; int mat = rules.GetLSLIntegerItem(idx++); if (mat < 0 || mat > 7) return; part.Material = Convert.ToByte(mat); break; case (int)ScriptBaseClass.PRIM_PHANTOM: if (remain < 1) return; string ph = rules.Data[idx++].ToString(); bool phantom; if (ph.Equals("1")) phantom = true; else phantom = false; part.ScriptSetPhantomStatus(phantom); break; case (int)ScriptBaseClass.PRIM_PHYSICS: if (remain < 1) return; string phy = rules.Data[idx++].ToString(); bool physics; if (phy.Equals("1")) physics = true; else physics = false; part.ScriptSetPhysicsStatus(physics); break; case (int)ScriptBaseClass.PRIM_TEMP_ON_REZ: if (remain < 1) return; string temp = rules.Data[idx++].ToString(); bool tempOnRez; if (temp.Equals("1")) tempOnRez = true; else tempOnRez = false; part.ScriptSetTemporaryStatus(tempOnRez); break; case (int)ScriptBaseClass.PRIM_TEXGEN: if (remain < 2) return; //face,type face = rules.GetLSLIntegerItem(idx++); int style = rules.GetLSLIntegerItem(idx++); SetTexGen(part, face, style); break; case (int)ScriptBaseClass.PRIM_TEXT: if (remain < 3) return; string primText = rules.GetLSLStringItem(idx++); LSL_Vector primTextColor = rules.GetVector3Item(idx++); LSL_Float primTextAlpha = rules.GetLSLFloatItem(idx++); Vector3 av3 = new Vector3(Util.Clip((float)primTextColor.x, 0.0f, 1.0f), Util.Clip((float)primTextColor.y, 0.0f, 1.0f), Util.Clip((float)primTextColor.z, 0.0f, 1.0f)); part.SetText(primText, av3, Util.Clip((float)primTextAlpha, 0.0f, 1.0f)); break; case (int)ScriptBaseClass.PRIM_NAME: if (remain < 1) return; string primName = rules.GetLSLStringItem(idx++); part.Name = primName; break; case (int)ScriptBaseClass.PRIM_DESC: if (remain < 1) return; string primDesc = rules.GetLSLStringItem(idx++); part.Description = primDesc; break; case (int)ScriptBaseClass.PRIM_ROT_LOCAL: if (remain < 1) return; LSL_Rotation lr = rules.GetQuaternionItem(idx++); SetRot(part, Rot2Quaternion(lr)); break; } } }
public void llSetKeyframedMotion(LSL_List frames, LSL_List options) { SceneObjectGroup group = m_host.ParentGroup; if (group.RootPart.PhysActor != null && group.RootPart.PhysActor.IsPhysical) return; if (group.IsAttachment) return; if (frames.Data.Length > 0) // We are getting a new motion { if (group.RootPart.KeyframeMotion != null) group.RootPart.KeyframeMotion.Delete(); group.RootPart.KeyframeMotion = null; int idx = 0; KeyframeMotion.PlayMode mode = KeyframeMotion.PlayMode.Forward; KeyframeMotion.DataFormat data = KeyframeMotion.DataFormat.Translation | KeyframeMotion.DataFormat.Rotation; while (idx < options.Data.Length) { int option = (int)options.GetLSLIntegerItem(idx++); int remain = options.Data.Length - idx; switch (option) { case ScriptBaseClass.KFM_MODE: if (remain < 1) break; int modeval = (int)options.GetLSLIntegerItem(idx++); switch(modeval) { case ScriptBaseClass.KFM_FORWARD: mode = KeyframeMotion.PlayMode.Forward; break; case ScriptBaseClass.KFM_REVERSE: mode = KeyframeMotion.PlayMode.Reverse; break; case ScriptBaseClass.KFM_LOOP: mode = KeyframeMotion.PlayMode.Loop; break; case ScriptBaseClass.KFM_PING_PONG: mode = KeyframeMotion.PlayMode.PingPong; break; } break; case ScriptBaseClass.KFM_DATA: if (remain < 1) break; int dataval = (int)options.GetLSLIntegerItem(idx++); data = (KeyframeMotion.DataFormat)dataval; break; } } group.RootPart.KeyframeMotion = new KeyframeMotion(group, mode, data); idx = 0; int elemLength = 2; if (data == (KeyframeMotion.DataFormat.Translation | KeyframeMotion.DataFormat.Rotation)) elemLength = 3; List<KeyframeMotion.Keyframe> keyframes = new List<KeyframeMotion.Keyframe>(); while (idx < frames.Data.Length) { int remain = frames.Data.Length - idx; if (remain < elemLength) break; KeyframeMotion.Keyframe frame = new KeyframeMotion.Keyframe(); frame.Position = null; frame.Rotation = null; if ((data & KeyframeMotion.DataFormat.Translation) != 0) { LSL_Types.Vector3 tempv = frames.GetVector3Item(idx++); frame.Position = new Vector3((float)tempv.x, (float)tempv.y, (float)tempv.z); } if ((data & KeyframeMotion.DataFormat.Rotation) != 0) { LSL_Types.Quaternion tempq = frames.GetQuaternionItem(idx++); Quaternion q = new Quaternion((float)tempq.x, (float)tempq.y, (float)tempq.z, (float)tempq.s); q.Normalize(); frame.Rotation = q; } float tempf = (float)frames.GetLSLFloatItem(idx++); frame.TimeMS = (int)(tempf * 1000.0f); keyframes.Add(frame); } group.RootPart.KeyframeMotion.SetKeyframes(keyframes.ToArray()); group.RootPart.KeyframeMotion.Start(); } else { if (group.RootPart.KeyframeMotion == null) return; if (options.Data.Length == 0) { group.RootPart.KeyframeMotion.Stop(); return; } int idx = 0; while (idx < options.Data.Length) { int option = (int)options.GetLSLIntegerItem(idx++); switch (option) { case ScriptBaseClass.KFM_COMMAND: int cmd = (int)options.GetLSLIntegerItem(idx++); switch (cmd) { case ScriptBaseClass.KFM_CMD_PLAY: group.RootPart.KeyframeMotion.Start(); break; case ScriptBaseClass.KFM_CMD_STOP: group.RootPart.KeyframeMotion.Stop(); break; case ScriptBaseClass.KFM_CMD_PAUSE: group.RootPart.KeyframeMotion.Pause(); break; } break; } } } }
private RegionLightShareData getWindlightProfileFromRules(LSL_List rules) { RegionLightShareData wl = (RegionLightShareData)m_host.ParentGroup.Scene.RegionInfo.WindlightSettings.Clone(); // LSL_List values = new LSL_List(); int idx = 0; while (idx < rules.Length) { uint rule; try { rule = (uint)rules.GetLSLIntegerItem(idx); } catch (InvalidCastException) { throw new InvalidCastException(string.Format("Error running rule type: arg #{0} - parameter type must be integer", idx)); } LSL_Types.Quaternion iQ; LSL_Types.Vector3 iV; switch (rule) { case (int)ScriptBaseClass.WL_SUN_MOON_POSITION: idx++; try { wl.sunMoonPosition = (float)rules.GetLSLFloatItem(idx); } catch (InvalidCastException) { throw new InvalidCastException(string.Format("Error running rule WL_SUN_MOON_POSITION: arg #{0} - parameter 1 must be float", idx)); } break; case (int)ScriptBaseClass.WL_AMBIENT: idx++; try { iQ = rules.GetQuaternionItem(idx); } catch (InvalidCastException) { throw new InvalidCastException(string.Format("Error running rule WL_AMBIENT: arg #{0} - parameter 1 must be rotation", idx)); } wl.ambient = new Vector4((float)iQ.x, (float)iQ.y, (float)iQ.z, (float)iQ.s); break; case (int)ScriptBaseClass.WL_BIG_WAVE_DIRECTION: idx++; try { iV = rules.GetVector3Item(idx); } catch (InvalidCastException) { throw new InvalidCastException(string.Format("Error running rule WL_BIG_WAVE_DIRECTION: arg #{0} - parameter 1 must be vector", idx)); } wl.bigWaveDirection = new Vector2((float)iV.x, (float)iV.y); break; case (int)ScriptBaseClass.WL_BLUE_DENSITY: idx++; try { iQ = rules.GetQuaternionItem(idx); } catch (InvalidCastException) { throw new InvalidCastException(string.Format("Error running rule WL_BLUE_DENSITY: arg #{0} - parameter 1 must be rotation", idx)); } wl.blueDensity = new Vector4((float)iQ.x, (float)iQ.y, (float)iQ.z, (float)iQ.s); break; case (int)ScriptBaseClass.WL_BLUR_MULTIPLIER: idx++; try { wl.blurMultiplier = (float)rules.GetLSLFloatItem(idx); } catch (InvalidCastException) { throw new InvalidCastException(string.Format("Error running rule WL_BLUR_MULTIPLIER: arg #{0} - parameter 1 must be float", idx)); } break; case (int)ScriptBaseClass.WL_CLOUD_COLOR: idx++; try { iQ = rules.GetQuaternionItem(idx); } catch (InvalidCastException) { throw new InvalidCastException(string.Format("Error running rule WL_CLOUD_COLOR: arg #{0} - parameter 1 must be rotation", idx)); } wl.cloudColor = new Vector4((float)iQ.x, (float)iQ.y, (float)iQ.z, (float)iQ.s); break; case (int)ScriptBaseClass.WL_CLOUD_COVERAGE: idx++; try { wl.cloudCoverage = (float)rules.GetLSLFloatItem(idx); } catch (InvalidCastException) { throw new InvalidCastException(string.Format("Error running rule WL_CLOUD_COVERAGE: arg #{0} - parameter 1 must be float", idx)); } break; case (int)ScriptBaseClass.WL_CLOUD_DETAIL_XY_DENSITY: idx++; try { iV = rules.GetVector3Item(idx); } catch (InvalidCastException) { throw new InvalidCastException(string.Format("Error running rule WL_CLOUD_DETAIL_XY_DENSITY: arg #{0} - parameter 1 must be vector", idx)); } wl.cloudDetailXYDensity = iV; break; case (int)ScriptBaseClass.WL_CLOUD_SCALE: idx++; try { wl.cloudScale = (float)rules.GetLSLFloatItem(idx); } catch (InvalidCastException) { throw new InvalidCastException(string.Format("Error running rule WL_CLOUD_SCALE: arg #{0} - parameter 1 must be float", idx)); } break; case (int)ScriptBaseClass.WL_CLOUD_SCROLL_X: idx++; try { wl.cloudScrollX = (float)rules.GetLSLFloatItem(idx); } catch (InvalidCastException) { throw new InvalidCastException(string.Format("Error running rule WL_CLOUD_SCROLL_X: arg #{0} - parameter 1 must be float", idx)); } break; case (int)ScriptBaseClass.WL_CLOUD_SCROLL_X_LOCK: idx++; try { wl.cloudScrollXLock = rules.GetLSLIntegerItem(idx).value == 1 ? true : false; } catch (InvalidCastException) { throw new InvalidCastException(string.Format("Error running rule WL_CLOUD_SCROLL_Y_LOCK: arg #{0} - parameter 1 must be integer", idx)); } break; case (int)ScriptBaseClass.WL_CLOUD_SCROLL_Y: idx++; try { wl.cloudScrollY = (float)rules.GetLSLFloatItem(idx); } catch (InvalidCastException) { throw new InvalidCastException(string.Format("Error running rule WL_CLOUD_SCROLL_Y: arg #{0} - parameter 1 must be float", idx)); } break; case (int)ScriptBaseClass.WL_CLOUD_SCROLL_Y_LOCK: idx++; try { wl.cloudScrollYLock = rules.GetLSLIntegerItem(idx).value == 1 ? true : false; } catch (InvalidCastException) { throw new InvalidCastException(string.Format("Error running rule WL_CLOUD_SCROLL_Y_LOCK: arg #{0} - parameter 1 must be integer", idx)); } break; case (int)ScriptBaseClass.WL_CLOUD_XY_DENSITY: idx++; try { iV = rules.GetVector3Item(idx); } catch (InvalidCastException) { throw new InvalidCastException(string.Format("Error running rule WL_CLOUD_XY_DENSITY: arg #{0} - parameter 1 must be vector", idx)); } wl.cloudXYDensity = iV; break; case (int)ScriptBaseClass.WL_DENSITY_MULTIPLIER: idx++; try { wl.densityMultiplier = (float)rules.GetLSLFloatItem(idx); } catch (InvalidCastException) { throw new InvalidCastException(string.Format("Error running rule WL_DENSITY_MULTIPLIER: arg #{0} - parameter 1 must be float", idx)); } break; case (int)ScriptBaseClass.WL_DISTANCE_MULTIPLIER: idx++; try { wl.distanceMultiplier = (float)rules.GetLSLFloatItem(idx); } catch (InvalidCastException) { throw new InvalidCastException(string.Format("Error running rule WL_DISTANCE_MULTIPLIER: arg #{0} - parameter 1 must be float", idx)); } break; case (int)ScriptBaseClass.WL_DRAW_CLASSIC_CLOUDS: idx++; try { wl.drawClassicClouds = rules.GetLSLIntegerItem(idx).value == 1 ? true : false; } catch (InvalidCastException) { throw new InvalidCastException(string.Format("Error running rule WL_DRAW_CLASSIC_CLOUDS: arg #{0} - parameter 1 must be integer", idx)); } break; case (int)ScriptBaseClass.WL_EAST_ANGLE: idx++; try { wl.eastAngle = (float)rules.GetLSLFloatItem(idx); } catch (InvalidCastException) { throw new InvalidCastException(string.Format("Error running rule WL_EAST_ANGLE: arg #{0} - parameter 1 must be float", idx)); } break; case (int)ScriptBaseClass.WL_FRESNEL_OFFSET: idx++; try { wl.fresnelOffset = (float)rules.GetLSLFloatItem(idx); } catch (InvalidCastException) { throw new InvalidCastException(string.Format("Error running rule WL_FRESNEL_OFFSET: arg #{0} - parameter 1 must be float", idx)); } break; case (int)ScriptBaseClass.WL_FRESNEL_SCALE: idx++; try { wl.fresnelScale = (float)rules.GetLSLFloatItem(idx); } catch (InvalidCastException) { throw new InvalidCastException(string.Format("Error running rule WL_FRESNEL_SCALE: arg #{0} - parameter 1 must be float", idx)); } break; case (int)ScriptBaseClass.WL_HAZE_DENSITY: idx++; try { wl.hazeDensity = (float)rules.GetLSLFloatItem(idx); } catch (InvalidCastException) { throw new InvalidCastException(string.Format("Error running rule WL_HAZE_DENSITY: arg #{0} - parameter 1 must be float", idx)); } break; case (int)ScriptBaseClass.WL_HAZE_HORIZON: idx++; try { wl.hazeHorizon = (float)rules.GetLSLFloatItem(idx); } catch (InvalidCastException) { throw new InvalidCastException(string.Format("Error running rule WL_HAZE_HORIZON: arg #{0} - parameter 1 must be float", idx)); } break; case (int)ScriptBaseClass.WL_HORIZON: idx++; try { iQ = rules.GetQuaternionItem(idx); } catch (InvalidCastException) { throw new InvalidCastException(string.Format("Error running rule WL_HORIZON: arg #{0} - parameter 1 must be rotation", idx)); } wl.horizon = new Vector4((float)iQ.x, (float)iQ.y, (float)iQ.z, (float)iQ.s); break; case (int)ScriptBaseClass.WL_LITTLE_WAVE_DIRECTION: idx++; try { iV = rules.GetVector3Item(idx); } catch (InvalidCastException) { throw new InvalidCastException(string.Format("Error running rule WL_LITTLE_WAVE_DIRECTION: arg #{0} - parameter 1 must be vector", idx)); } wl.littleWaveDirection = new Vector2((float)iV.x, (float)iV.y); break; case (int)ScriptBaseClass.WL_MAX_ALTITUDE: idx++; try { wl.maxAltitude = (ushort)rules.GetLSLIntegerItem(idx).value; } catch (InvalidCastException) { throw new InvalidCastException(string.Format("Error running rule WL_MAX_ALTITUDE: arg #{0} - parameter 1 must be integer", idx)); } break; case (int)ScriptBaseClass.WL_NORMAL_MAP_TEXTURE: idx++; try { wl.normalMapTexture = new UUID(rules.GetLSLStringItem(idx).m_string); } catch (ArgumentException) { throw new InvalidCastException(string.Format("Error running rule WL_NORMAL_MAP_TEXTURE: arg #{0} - parameter 1 must be key", idx)); } break; case (int)ScriptBaseClass.WL_REFLECTION_WAVELET_SCALE: idx++; try { iV = rules.GetVector3Item(idx); } catch (InvalidCastException) { throw new InvalidCastException(string.Format("Error running rule WL_REFLECTION_WAVELET_SCALE: arg #{0} - parameter 1 must be vector", idx)); } wl.reflectionWaveletScale = iV; break; case (int)ScriptBaseClass.WL_REFRACT_SCALE_ABOVE: idx++; try { wl.refractScaleAbove = (float)rules.GetLSLFloatItem(idx); } catch (InvalidCastException) { throw new InvalidCastException(string.Format("Error running rule WL_REFRACT_SCALE_ABOVE: arg #{0} - parameter 1 must be float", idx)); } break; case (int)ScriptBaseClass.WL_REFRACT_SCALE_BELOW: idx++; try { wl.refractScaleBelow = (float)rules.GetLSLFloatItem(idx); } catch (InvalidCastException) { throw new InvalidCastException(string.Format("Error running rule WL_REFRACT_SCALE_BELOW: arg #{0} - parameter 1 must be float", idx)); } break; case (int)ScriptBaseClass.WL_SCENE_GAMMA: idx++; try { wl.sceneGamma = (float)rules.GetLSLFloatItem(idx); } catch (InvalidCastException) { throw new InvalidCastException(string.Format("Error running rule WL_SCENE_GAMMA: arg #{0} - parameter 1 must be float", idx)); } break; case (int)ScriptBaseClass.WL_STAR_BRIGHTNESS: idx++; try { wl.starBrightness = (float)rules.GetLSLFloatItem(idx); } catch (InvalidCastException) { throw new InvalidCastException(string.Format("Error running rule WL_STAR_BRIGHTNESS: arg #{0} - parameter 1 must be float", idx)); } break; case (int)ScriptBaseClass.WL_SUN_GLOW_FOCUS: idx++; try { wl.sunGlowFocus = (float)rules.GetLSLFloatItem(idx); } catch (InvalidCastException) { throw new InvalidCastException(string.Format("Error running rule WL_SUN_GLOW_FOCUS: arg #{0} - parameter 1 must be float", idx)); } break; case (int)ScriptBaseClass.WL_SUN_GLOW_SIZE: idx++; try { wl.sunGlowSize = (float)rules.GetLSLFloatItem(idx); } catch (InvalidCastException) { throw new InvalidCastException(string.Format("Error running rule WL_SUN_GLOW_SIZE: arg #{0} - parameter 1 must be float", idx)); } break; case (int)ScriptBaseClass.WL_SUN_MOON_COLOR: idx++; iQ = rules.GetQuaternionItem(idx); try { wl.sunMoonColor = new Vector4((float)iQ.x, (float)iQ.y, (float)iQ.z, (float)iQ.s); } catch (InvalidCastException) { throw new InvalidCastException(string.Format("Error running rule WL_SUN_MOON_COLOR: arg #{0} - parameter 1 must be rotation", idx)); } break; case (int)ScriptBaseClass.WL_UNDERWATER_FOG_MODIFIER: idx++; try { wl.underwaterFogModifier = (float)rules.GetLSLFloatItem(idx); } catch (InvalidCastException) { throw new InvalidCastException(string.Format("Error running rule WL_UNDERWATER_FOG_MODIFIER: arg #{0} - parameter 1 must be float", idx)); } break; case (int)ScriptBaseClass.WL_WATER_COLOR: idx++; try { iV = rules.GetVector3Item(idx); } catch (InvalidCastException) { throw new InvalidCastException(string.Format("Error running rule WL_WATER_COLOR: arg #{0} - parameter 1 must be vector", idx)); } wl.waterColor = iV; break; case (int)ScriptBaseClass.WL_WATER_FOG_DENSITY_EXPONENT: idx++; try { wl.waterFogDensityExponent = (float)rules.GetLSLFloatItem(idx); } catch (InvalidCastException) { throw new InvalidCastException(string.Format("Error running rule WL_WATER_FOG_DENSITY_EXPONENT: arg #{0} - parameter 1 must be float", idx)); } break; } idx++; } return wl; }
protected LSL_List SetAgentParams(ScenePresence sp, LSL_List rules, string originFunc, ref uint rulesParsed) { int idx = 0; int idxStart = 0; try { while (idx < rules.Length) { ++rulesParsed; int code = rules.GetLSLIntegerItem(idx++); int remain = rules.Length - idx; idxStart = idx; switch (code) { case ScriptBaseClass.PRIM_POSITION: case ScriptBaseClass.PRIM_POS_LOCAL: if (remain < 1) return new LSL_List(); try { sp.OffsetPosition = rules.GetVector3Item(idx++); } catch(InvalidCastException) { if (code == ScriptBaseClass.PRIM_POSITION) { Error(originFunc, string.Format("Error running rule #{0} -> PRIM_POSITION: arg #{1} - parameter 2 must be vector", rulesParsed, idx - idxStart - 1)); } else { Error(originFunc, string.Format("Error running rule #{0} -> PRIM_POS_LOCAL: arg #{1} - parameter 2 must be vector", rulesParsed, idx - idxStart - 1)); } return new LSL_List(); } break; case ScriptBaseClass.PRIM_ROTATION: if (remain < 1) return new LSL_List(); Quaternion inRot; try { inRot = rules.GetQuaternionItem(idx++); } catch(InvalidCastException) { Error(originFunc, string.Format("Error running rule #{0} -> PRIM_ROTATION: arg #{1} - parameter 2 must be rotation", rulesParsed, idx - idxStart - 1)); return new LSL_List(); } SceneObjectPart parentPart = sp.ParentPart; if (parentPart != null) sp.Rotation = m_host.GetWorldRotation() * inRot; break; case ScriptBaseClass.PRIM_ROT_LOCAL: if (remain < 1) return new LSL_List(); try { sp.Rotation = rules.GetQuaternionItem(idx++); } catch(InvalidCastException) { Error(originFunc, string.Format("Error running rule #{0} -> PRIM_ROT_LOCAL: arg #{1} - parameter 2 must be rotation", rulesParsed, idx - idxStart - 1)); return new LSL_List(); } break; case ScriptBaseClass.PRIM_TYPE: Error(originFunc, "PRIM_TYPE disallowed on agent"); return new LSL_List(); case ScriptBaseClass.PRIM_OMEGA: Error(originFunc, "PRIM_OMEGA disallowed on agent"); return new LSL_List(); case ScriptBaseClass.PRIM_LINK_TARGET: if (remain < 3) // setting to 3 on the basis that parsing any usage of PRIM_LINK_TARGET that has nothing following it is pointless. return new LSL_List(); return rules.GetSublist(idx, -1); default: Error(originFunc, string.Format("Error running rule #{0} on agent: arg #{1} - disallowed on agent", rulesParsed, idx - idxStart)); return new LSL_List(); } } } catch (InvalidCastException e) { Error( originFunc, string.Format("Error running rule #{0}: arg #{1} - ", rulesParsed, idx - idxStart) + e.Message); } return new LSL_List(); }
protected LSL_List SetPrimParams(SceneObjectPart part, LSL_List rules, string originFunc, ref uint rulesParsed) { int idx = 0; int idxStart = 0; bool positionChanged = false; LSL_Vector currentPosition = GetPartLocalPos(part); try { while (idx < rules.Length) { ++rulesParsed; int code = rules.GetLSLIntegerItem(idx++); int remain = rules.Length - idx; idxStart = idx; int face; LSL_Vector v; switch (code) { case ScriptBaseClass.PRIM_POSITION: case ScriptBaseClass.PRIM_POS_LOCAL: if (remain < 1) return new LSL_List(); try { v = rules.GetVector3Item(idx++); } catch(InvalidCastException) { if(code == ScriptBaseClass.PRIM_POSITION) Error(originFunc, string.Format("Error running rule #{0} -> PRIM_POSITION: arg #{1} - parameter 1 must be vector", rulesParsed, idx - idxStart - 1)); else Error(originFunc, string.Format("Error running rule #{0} -> PRIM_POS_LOCAL: arg #{1} - parameter 1 must be vector", rulesParsed, idx - idxStart - 1)); return new LSL_List(); } positionChanged = true; currentPosition = GetSetPosTarget(part, v, currentPosition); break; case ScriptBaseClass.PRIM_SIZE: if (remain < 1) return new LSL_List(); v=rules.GetVector3Item(idx++); SetScale(part, v); break; case ScriptBaseClass.PRIM_ROTATION: if (remain < 1) return new LSL_List(); LSL_Rotation q; try { q = rules.GetQuaternionItem(idx++); } catch(InvalidCastException) { Error(originFunc, string.Format("Error running rule #{0} -> PRIM_ROTATION: arg #{1} - parameter 1 must be rotation", rulesParsed, idx - idxStart - 1)); return new LSL_List(); } // try to let this work as in SL... if (part.ParentID == 0) { // special case: If we are root, rotate complete SOG to new rotation SetRot(part, q); } else { // we are a child. The rotation values will be set to the one of root modified by rot, as in SL. Don't ask. SceneObjectPart rootPart = part.ParentGroup.RootPart; SetRot(part, rootPart.RotationOffset * (Quaternion)q); } break; case ScriptBaseClass.PRIM_TYPE: if (remain < 3) return new LSL_List(); try { code = (int)rules.GetLSLIntegerItem(idx++); } catch(InvalidCastException) { Error(originFunc, string.Format("Error running rule #{0} -> PRIM_TYPE: arg #{1} - parameter 1 must be integer", rulesParsed, idx - idxStart - 1)); return new LSL_List(); } remain = rules.Length - idx; float hollow; LSL_Vector twist; LSL_Vector taper_b; LSL_Vector topshear; float revolutions; float radiusoffset; float skew; LSL_Vector holesize; LSL_Vector profilecut; switch (code) { case ScriptBaseClass.PRIM_TYPE_BOX: if (remain < 6) return new LSL_List(); try { face = (int)rules.GetLSLIntegerItem(idx++); } catch(InvalidCastException) { Error(originFunc, string.Format("Error running rule #{0} -> PRIM_TYPE, PRIM_TYPE_BOX: arg #{1} - parameter 2 must be integer", rulesParsed, idx - idxStart - 1)); return new LSL_List(); } try { v = rules.GetVector3Item(idx++); // cut } catch(InvalidCastException) { Error(originFunc, string.Format("Error running rule #{0} -> PRIM_TYPE, PRIM_TYPE_BOX: arg #{1} - parameter 3 must be vector", rulesParsed, idx - idxStart - 1)); return new LSL_List(); } try { hollow = (float)rules.GetLSLFloatItem(idx++); } catch(InvalidCastException) { Error(originFunc, string.Format("Error running rule #{0} -> PRIM_TYPE, PRIM_TYPE_BOX: arg #{1} - parameter 4 must be float", rulesParsed, idx - idxStart - 1)); return new LSL_List(); } try { twist = rules.GetVector3Item(idx++); } catch(InvalidCastException) { Error(originFunc, string.Format("Error running rule #{0} -> PRIM_TYPE, PRIM_TYPE_BOX: arg #{1} - parameter 5 must be vector", rulesParsed, idx - idxStart - 1)); return new LSL_List(); } try { taper_b = rules.GetVector3Item(idx++); } catch(InvalidCastException) { Error(originFunc, string.Format("Error running rule #{0} -> PRIM_TYPE, PRIM_TYPE_BOX: arg #{1} - parameter 6 must be vector", rulesParsed, idx - idxStart - 1)); return new LSL_List(); } try { topshear = rules.GetVector3Item(idx++); } catch(InvalidCastException) { Error(originFunc, string.Format("Error running rule #{0} -> PRIM_TYPE, PRIM_TYPE_BOX: arg #{1} - parameter 7 must be vector", rulesParsed, idx - idxStart - 1)); return new LSL_List(); } SetPrimitiveShapeParams(part, face, v, hollow, twist, taper_b, topshear, (byte)ProfileShape.Square, (byte)Extrusion.Straight); break; case ScriptBaseClass.PRIM_TYPE_CYLINDER: if (remain < 6) return new LSL_List(); try { face = (int)rules.GetLSLIntegerItem(idx++); // holeshape } catch(InvalidCastException) { Error(originFunc, string.Format("Error running rule #{0} -> PRIM_TYPE, PRIM_TYPE_CYLINDER: arg #{1} - parameter 3 must be integer", rulesParsed, idx - idxStart - 1)); return new LSL_List(); } try { v = rules.GetVector3Item(idx++); // cut } catch(InvalidCastException) { Error(originFunc, string.Format("Error running rule #{0} -> PRIM_TYPE, PRIM_TYPE_CYLINDER: arg #{1} - parameter 4 must be vector", rulesParsed, idx - idxStart - 1)); return new LSL_List(); } try { hollow = (float)rules.GetLSLFloatItem(idx++); } catch(InvalidCastException) { Error(originFunc, string.Format("Error running rule #{0} -> PRIM_TYPE, PRIM_TYPE_CYLINDER: arg #{1} - parameter 5 must be float", rulesParsed, idx - idxStart - 1)); return new LSL_List(); } try { twist = rules.GetVector3Item(idx++); } catch(InvalidCastException) { Error(originFunc, string.Format("Error running rule #{0} -> PRIM_TYPE, PRIM_TYPE_CYLINDER: arg #{1} - parameter 6 must be vector", rulesParsed, idx - idxStart - 1)); return new LSL_List(); } try { taper_b = rules.GetVector3Item(idx++); } catch(InvalidCastException) { Error(originFunc, string.Format("Error running rule #{0} -> PRIM_TYPE, PRIM_TYPE_CYLINDER: arg #{1} - parameter 7 must be vector", rulesParsed, idx - idxStart - 1)); return new LSL_List(); } try { topshear = rules.GetVector3Item(idx++); } catch(InvalidCastException) { Error(originFunc, string.Format("Error running rule #{0} -> PRIM_TYPE, PRIM_TYPE_CYLINDER: arg #{1} - parameter 8 must be vector", rulesParsed, idx - idxStart - 1)); return new LSL_List(); } SetPrimitiveShapeParams(part, face, v, hollow, twist, taper_b, topshear, (byte)ProfileShape.Circle, (byte)Extrusion.Straight); break; case ScriptBaseClass.PRIM_TYPE_PRISM: if (remain < 6) return new LSL_List(); try { face = (int)rules.GetLSLIntegerItem(idx++); // holeshape } catch(InvalidCastException) { Error(originFunc, string.Format("Error running rule #{0} -> PRIM_TYPE, PRIM_TYPE_PRISM: arg #{1} - parameter 3 must be integer", rulesParsed, idx - idxStart - 1)); return new LSL_List(); } try { v = rules.GetVector3Item(idx++); //cut } catch(InvalidCastException) { Error(originFunc, string.Format("Error running rule #{0} -> PRIM_TYPE, PRIM_TYPE_PRISM: arg #{1} - parameter 4 must be vector", rulesParsed, idx - idxStart - 1)); return new LSL_List(); } try { hollow = (float)rules.GetLSLFloatItem(idx++); } catch(InvalidCastException) { Error(originFunc, string.Format("Error running rule #{0} -> PRIM_TYPE, PRIM_TYPE_PRISM: arg #{1} - parameter 5 must be float", rulesParsed, idx - idxStart - 1)); return new LSL_List(); } try { twist = rules.GetVector3Item(idx++); } catch(InvalidCastException) { Error(originFunc, string.Format("Error running rule #{0} -> PRIM_TYPE, PRIM_TYPE_PRISM: arg #{1} - parameter 6 must be vector", rulesParsed, idx - idxStart - 1)); return new LSL_List(); } try { taper_b = rules.GetVector3Item(idx++); } catch(InvalidCastException) { Error(originFunc, string.Format("Error running rule #{0} -> PRIM_TYPE, PRIM_TYPE_PRISM: arg #{1} - parameter 7 must be vector", rulesParsed, idx - idxStart - 1)); return new LSL_List(); } try { topshear = rules.GetVector3Item(idx++); } catch(InvalidCastException) { Error(originFunc, string.Format("Error running rule #{0} -> PRIM_TYPE, PRIM_TYPE_PRISM: arg #{1} - parameter 8 must be vector", rulesParsed, idx - idxStart - 1)); return new LSL_List(); } SetPrimitiveShapeParams(part, face, v, hollow, twist, taper_b, topshear, (byte)ProfileShape.EquilateralTriangle, (byte)Extrusion.Straight); break; case ScriptBaseClass.PRIM_TYPE_SPHERE: if (remain < 5) return new LSL_List(); try { face = (int)rules.GetLSLIntegerItem(idx++); // holeshape } catch(InvalidCastException) { Error(originFunc, string.Format("Error running rule #{0} -> PRIM_TYPE, PRIM_TYPE_SPHERE: arg #{1} - parameter 3 must be integer", rulesParsed, idx - idxStart - 1)); return new LSL_List(); } try { v = rules.GetVector3Item(idx++); // cut } catch(InvalidCastException) { Error(originFunc, string.Format("Error running rule #{0} -> PRIM_TYPE, PRIM_TYPE_SPHERE: arg #{1} - parameter 4 must be vector", rulesParsed, idx - idxStart - 1)); return new LSL_List(); } try { hollow = (float)rules.GetLSLFloatItem(idx++); } catch(InvalidCastException) { Error(originFunc, string.Format("Error running rule #{0} -> PRIM_TYPE, PRIM_TYPE_SPHERE: arg #{1} - parameter 5 must be float", rulesParsed, idx - idxStart - 1)); return new LSL_List(); } try { twist = rules.GetVector3Item(idx++); } catch(InvalidCastException) { Error(originFunc, string.Format("Error running rule #{0} -> PRIM_TYPE, PRIM_TYPE_SPHERE: arg #{1} - parameter 6 must be vector", rulesParsed, idx - idxStart - 1)); return new LSL_List(); } try { taper_b = rules.GetVector3Item(idx++); // dimple } catch(InvalidCastException) { Error(originFunc, string.Format("Error running rule #{0} -> PRIM_TYPE, PRIM_TYPE_SPHERE: arg #{1} - parameter 7 must be vector", rulesParsed, idx - idxStart - 1)); return new LSL_List(); } SetPrimitiveShapeParams(part, face, v, hollow, twist, taper_b, (byte)ProfileShape.HalfCircle, (byte)Extrusion.Curve1); break; case ScriptBaseClass.PRIM_TYPE_TORUS: if (remain < 11) return new LSL_List(); try { face = (int)rules.GetLSLIntegerItem(idx++); // holeshape } catch(InvalidCastException) { Error(originFunc, string.Format("Error running rule #{0} -> PRIM_TYPE, PRIM_TYPE_TORUS: arg #{1} - parameter 3 must be integer", rulesParsed, idx - idxStart - 1)); return new LSL_List(); } try { v = rules.GetVector3Item(idx++); //cut } catch(InvalidCastException) { Error(originFunc, string.Format("Error running rule #{0} -> PRIM_TYPE, PRIM_TYPE_TORUS: arg #{1} - parameter 4 must be vector", rulesParsed, idx - idxStart - 1)); return new LSL_List(); } try { hollow = (float)rules.GetLSLFloatItem(idx++); } catch(InvalidCastException) { Error(originFunc, string.Format("Error running rule #{0} -> PRIM_TYPE, PRIM_TYPE_TORUS: arg #{1} - parameter 5 must be float", rulesParsed, idx - idxStart - 1)); return new LSL_List(); } try { twist = rules.GetVector3Item(idx++); } catch(InvalidCastException) { Error(originFunc, string.Format("Error running rule #{0} -> PRIM_TYPE, PRIM_TYPE_TORUS: arg #{1} - parameter 6 must be vector", rulesParsed, idx - idxStart - 1)); return new LSL_List(); } try { holesize = rules.GetVector3Item(idx++); } catch(InvalidCastException) { Error(originFunc, string.Format("Error running rule #{0} -> PRIM_TYPE, PRIM_TYPE_TORUS: arg #{1} - parameter 7 must be vector", rulesParsed, idx - idxStart - 1)); return new LSL_List(); } try { topshear = rules.GetVector3Item(idx++); } catch(InvalidCastException) { Error(originFunc, string.Format("Error running rule #{0} -> PRIM_TYPE, PRIM_TYPE_TORUS: arg #{1} - parameter 8 must be vector", rulesParsed, idx - idxStart - 1)); return new LSL_List(); } try { profilecut = rules.GetVector3Item(idx++); } catch(InvalidCastException) { Error(originFunc, string.Format("Error running rule #{0} -> PRIM_TYPE, PRIM_TYPE_TORUS: arg #{1} - parameter 9 must be vector", rulesParsed, idx - idxStart - 1)); return new LSL_List(); } try { taper_b = rules.GetVector3Item(idx++); // taper_a } catch(InvalidCastException) { Error(originFunc, string.Format("Error running rule #{0} -> PRIM_TYPE, PRIM_TYPE_TORUS: arg #{1} - parameter 10 must be vector", rulesParsed, idx - idxStart - 1)); return new LSL_List(); } try { revolutions = (float)rules.GetLSLFloatItem(idx++); } catch(InvalidCastException) { Error(originFunc, string.Format("Error running rule #{0} -> PRIM_TYPE, PRIM_TYPE_TORUS: arg #{1} - parameter 11 must be float", rulesParsed, idx - idxStart - 1)); return new LSL_List(); } try { radiusoffset = (float)rules.GetLSLFloatItem(idx++); } catch(InvalidCastException) { Error(originFunc, string.Format("Error running rule #{0} -> PRIM_TYPE, PRIM_TYPE_TORUS: arg #{1} - parameter 12 must be float", rulesParsed, idx - idxStart - 1)); return new LSL_List(); } try { skew = (float)rules.GetLSLFloatItem(idx++); } catch(InvalidCastException) { Error(originFunc, string.Format("Error running rule #{0} -> PRIM_TYPE, PRIM_TYPE_TORUS: arg #{1} - parameter 13 must be vector", rulesParsed, idx - idxStart - 1)); return new LSL_List(); } SetPrimitiveShapeParams(part, face, v, hollow, twist, holesize, topshear, profilecut, taper_b, revolutions, radiusoffset, skew, (byte)ProfileShape.Circle, (byte)Extrusion.Curve1); break; case ScriptBaseClass.PRIM_TYPE_TUBE: if (remain < 11) return new LSL_List(); try { face = (int)rules.GetLSLIntegerItem(idx++); // holeshape } catch(InvalidCastException) { Error(originFunc, string.Format("Error running rule #{0} -> PRIM_TYPE, PRIM_TYPE_TUBE: arg #{1} - parameter 3 must be integer", rulesParsed, idx - idxStart - 1)); return new LSL_List(); } try { v = rules.GetVector3Item(idx++); //cut } catch(InvalidCastException) { Error(originFunc, string.Format("Error running rule #{0} -> PRIM_TYPE, PRIM_TYPE_TUBE: arg #{1} - parameter 4 must be vector", rulesParsed, idx - idxStart - 1)); return new LSL_List(); } try { hollow = (float)rules.GetLSLFloatItem(idx++); } catch(InvalidCastException) { Error(originFunc, string.Format("Error running rule #{0} -> PRIM_TYPE, PRIM_TYPE_TUBE: arg #{1} - parameter 5 must be float", rulesParsed, idx - idxStart - 1)); return new LSL_List(); } try { twist = rules.GetVector3Item(idx++); } catch(InvalidCastException) { Error(originFunc, string.Format("Error running rule #{0} -> PRIM_TYPE, PRIM_TYPE_TUBE: arg #{1} - parameter 6 must be vector", rulesParsed, idx - idxStart - 1)); return new LSL_List(); } try { holesize = rules.GetVector3Item(idx++); } catch(InvalidCastException) { Error(originFunc, string.Format("Error running rule #{0} -> PRIM_TYPE, PRIM_TYPE_TUBE: arg #{1} - parameter 7 must be vector", rulesParsed, idx - idxStart - 1)); return new LSL_List(); } try { topshear = rules.GetVector3Item(idx++); } catch(InvalidCastException) { Error(originFunc, string.Format("Error running rule #{0} -> PRIM_TYPE, PRIM_TYPE_TUBE: arg #{1} - parameter 8 must be vector", rulesParsed, idx - idxStart - 1)); return new LSL_List(); } try { profilecut = rules.GetVector3Item(idx++); } catch(InvalidCastException) { Error(originFunc, string.Format("Error running rule #{0} -> PRIM_TYPE, PRIM_TYPE_TUBE: arg #{1} - parameter 9 must be vector", rulesParsed, idx - idxStart - 1)); return new LSL_List(); } try { taper_b = rules.GetVector3Item(idx++); // taper_a } catch(InvalidCastException) { Error(originFunc, string.Format("Error running rule #{0} -> PRIM_TYPE, PRIM_TYPE_TUBE: arg #{1} - parameter 10 must be vector", rulesParsed, idx - idxStart - 1)); return new LSL_List(); } try { revolutions = (float)rules.GetLSLFloatItem(idx++); } catch(InvalidCastException) { Error(originFunc, string.Format("Error running rule #{0} -> PRIM_TYPE, PRIM_TYPE_TUBE: arg #{1} - parameter 11 must be float", rulesParsed, idx - idxStart - 1)); return new LSL_List(); } try { radiusoffset = (float)rules.GetLSLFloatItem(idx++); } catch(InvalidCastException) { Error(originFunc, string.Format("Error running rule #{0} -> PRIM_TYPE, PRIM_TYPE_TUBE: arg #{1} - parameter 12 must be float", rulesParsed, idx - idxStart - 1)); return new LSL_List(); } try { skew = (float)rules.GetLSLFloatItem(idx++); } catch(InvalidCastException) { Error(originFunc, string.Format("Error running rule #{0} -> PRIM_TYPE, PRIM_TYPE_TUBE: arg #{1} - parameter 13 must be float", rulesParsed, idx - idxStart - 1)); return new LSL_List(); } SetPrimitiveShapeParams(part, face, v, hollow, twist, holesize, topshear, profilecut, taper_b, revolutions, radiusoffset, skew, (byte)ProfileShape.Square, (byte)Extrusion.Curve1); break; case ScriptBaseClass.PRIM_TYPE_RING: if (remain < 11) return new LSL_List(); try { face = (int)rules.GetLSLIntegerItem(idx++); // holeshape } catch(InvalidCastException) { Error(originFunc, string.Format("Error running rule #{0} -> PRIM_TYPE, PRIM_TYPE_RING: arg #{1} - parameter 3 must be integer", rulesParsed, idx - idxStart - 1)); return new LSL_List(); } try { v = rules.GetVector3Item(idx++); //cut } catch(InvalidCastException) { Error(originFunc, string.Format("Error running rule #{0} -> PRIM_TYPE, PRIM_TYPE_RING: arg #{1} - parameter 4 must be vector", rulesParsed, idx - idxStart - 1)); return new LSL_List(); } try { hollow = (float)rules.GetLSLFloatItem(idx++); } catch(InvalidCastException) { Error(originFunc, string.Format("Error running rule #{0} -> PRIM_TYPE, PRIM_TYPE_RING: arg #{1} - parameter 5 must be float", rulesParsed, idx - idxStart - 1)); return new LSL_List(); } try { twist = rules.GetVector3Item(idx++); } catch(InvalidCastException) { Error(originFunc, string.Format("Error running rule #{0} -> PRIM_TYPE, PRIM_TYPE_RING: arg #{1} - parameter 6 must be vector", rulesParsed, idx - idxStart - 1)); return new LSL_List(); } try { holesize = rules.GetVector3Item(idx++); } catch(InvalidCastException) { Error(originFunc, string.Format("Error running rule #{0} -> PRIM_TYPE, PRIM_TYPE_RING: arg #{1} - parameter 7 must be vector", rulesParsed, idx - idxStart - 1)); return new LSL_List(); } try { topshear = rules.GetVector3Item(idx++); } catch(InvalidCastException) { Error(originFunc, string.Format("Error running rule #{0} -> PRIM_TYPE, PRIM_TYPE_RING: arg #{1} - parameter 8 must be vector", rulesParsed, idx - idxStart - 1)); return new LSL_List(); } try { profilecut = rules.GetVector3Item(idx++); } catch(InvalidCastException) { Error(originFunc, string.Format("Error running rule #{0} -> PRIM_TYPE, PRIM_TYPE_RING: arg #{1} - parameter 9 must be vector", rulesParsed, idx - idxStart - 1)); return new LSL_List(); } try { taper_b = rules.GetVector3Item(idx++); // taper_a } catch(InvalidCastException) { Error(originFunc, string.Format("Error running rule #{0} -> PRIM_TYPE, PRIM_TYPE_RING: arg #{1} - parameter 10 must be vector", rulesParsed, idx - idxStart - 1)); return new LSL_List(); } try { revolutions = (float)rules.GetLSLFloatItem(idx++); } catch(InvalidCastException) { Error(originFunc, string.Format("Error running rule #{0} -> PRIM_TYPE, PRIM_TYPE_RING: arg #{1} - parameter 11 must be float", rulesParsed, idx - idxStart - 1)); return new LSL_List(); } try { radiusoffset = (float)rules.GetLSLFloatItem(idx++); } catch(InvalidCastException) { Error(originFunc, string.Format("Error running rule #{0} -> PRIM_TYPE, PRIM_TYPE_RING: arg #{1} - parameter 12 must be float", rulesParsed, idx - idxStart - 1)); return new LSL_List(); } try { skew = (float)rules.GetLSLFloatItem(idx++); } catch(InvalidCastException) { Error(originFunc, string.Format("Error running rule #{0} -> PRIM_TYPE, PRIM_TYPE_RING: arg #{1} - parameter 13 must be float", rulesParsed, idx - idxStart - 1)); return new LSL_List(); } SetPrimitiveShapeParams(part, face, v, hollow, twist, holesize, topshear, profilecut, taper_b, revolutions, radiusoffset, skew, (byte)ProfileShape.EquilateralTriangle, (byte)Extrusion.Curve1); break; case ScriptBaseClass.PRIM_TYPE_SCULPT: if (remain < 2) return new LSL_List(); string map = rules.Data[idx++].ToString(); try { face = (int)rules.GetLSLIntegerItem(idx++); // type } catch(InvalidCastException) { Error(originFunc, string.Format("Error running rule #{0} -> PRIM_TYPE, PRIM_TYPE_SCULPT: arg #{1} - parameter 4 must be integer", rulesParsed, idx - idxStart - 1)); return new LSL_List(); } SetPrimitiveShapeParams(part, map, face, (byte)Extrusion.Curve1); break; } break; case ScriptBaseClass.PRIM_TEXTURE: if (remain < 5) return new LSL_List(); face=(int)rules.GetLSLIntegerItem(idx++); string tex; LSL_Vector repeats; LSL_Vector offsets; double rotation; tex = rules.Data[idx++].ToString(); try { repeats = rules.GetVector3Item(idx++); } catch(InvalidCastException) { Error(originFunc, string.Format("Error running rule #{0} -> PRIM_TEXTURE: arg #{1} - parameter 3 must be vector", rulesParsed, idx - idxStart - 1)); return new LSL_List(); } try { offsets = rules.GetVector3Item(idx++); } catch(InvalidCastException) { Error(originFunc, string.Format("Error running rule #{0} -> PRIM_TEXTURE: arg #{1} - parameter 4 must be vector", rulesParsed, idx - idxStart - 1)); return new LSL_List(); } try { rotation = (double)rules.GetLSLFloatItem(idx++); } catch(InvalidCastException) { Error(originFunc, string.Format("Error running rule #{0} -> PRIM_TEXTURE: arg #{1} - parameter 5 must be float", rulesParsed, idx - idxStart - 1)); return new LSL_List(); } SetTexture(part, tex, face); ScaleTexture(part, repeats.x, repeats.y, face); OffsetTexture(part, offsets.x, offsets.y, face); RotateTexture(part, rotation, face); break; case ScriptBaseClass.PRIM_COLOR: if (remain < 3) return new LSL_List(); LSL_Vector color; double alpha; try { face = (int)rules.GetLSLIntegerItem(idx++); } catch(InvalidCastException) { Error(originFunc, string.Format("Error running rule #{0} -> PRIM_COLOR: arg #{1} - parameter 2 must be integer", rulesParsed, idx - idxStart - 1)); return new LSL_List(); } try { color = rules.GetVector3Item(idx++); } catch(InvalidCastException) { Error(originFunc, string.Format("Error running rule #{0} -> PRIM_COLOR: arg #{1} - parameter 3 must be vector", rulesParsed, idx - idxStart - 1)); return new LSL_List(); } try { alpha = (double)rules.GetLSLFloatItem(idx++); } catch(InvalidCastException) { Error(originFunc, string.Format("Error running rule #{0} -> PRIM_COLOR: arg #{1} - parameter 4 must be float", rulesParsed, idx - idxStart - 1)); return new LSL_List(); } part.SetFaceColorAlpha(face, color, alpha); break; case ScriptBaseClass.PRIM_FLEXIBLE: if (remain < 7) return new LSL_List(); bool flexi; int softness; float gravity; float friction; float wind; float tension; LSL_Vector force; try { flexi = rules.GetLSLIntegerItem(idx++); } catch(InvalidCastException) { Error(originFunc, string.Format("Error running rule #{0} -> PRIM_FLEXIBLE: arg #{1} - parameter 2 must be integer", rulesParsed, idx - idxStart - 1)); return new LSL_List(); } try { softness = rules.GetLSLIntegerItem(idx++); } catch(InvalidCastException) { Error(originFunc, string.Format("Error running rule #{0} -> PRIM_FLEXIBLE: arg #{1} - parameter 3 must be integer", rulesParsed, idx - idxStart - 1)); return new LSL_List(); } try { gravity = (float)rules.GetLSLFloatItem(idx++); } catch(InvalidCastException) { Error(originFunc, string.Format("Error running rule #{0} -> PRIM_FLEXIBLE: arg #{1} - parameter 4 must be float", rulesParsed, idx - idxStart - 1)); return new LSL_List(); } try { friction = (float)rules.GetLSLFloatItem(idx++); } catch(InvalidCastException) { Error(originFunc, string.Format("Error running rule #{0} -> PRIM_FLEXIBLE: arg #{1} - parameter 5 must be float", rulesParsed, idx - idxStart - 1)); return new LSL_List(); } try { wind = (float)rules.GetLSLFloatItem(idx++); } catch(InvalidCastException) { Error(originFunc, string.Format("Error running rule #{0} -> PRIM_FLEXIBLE: arg #{1} - parameter 6 must be float", rulesParsed, idx - idxStart - 1)); return new LSL_List(); } try { tension = (float)rules.GetLSLFloatItem(idx++); } catch(InvalidCastException) { Error(originFunc, string.Format("Error running rule #{0} -> PRIM_FLEXIBLE: arg #{1} - parameter 7 must be float", rulesParsed, idx - idxStart - 1)); return new LSL_List(); } try { force = rules.GetVector3Item(idx++); } catch(InvalidCastException) { Error(originFunc, string.Format("Error running rule #{0} -> PRIM_FLEXIBLE: arg #{1} - parameter 8 must be vector", rulesParsed, idx - idxStart - 1)); return new LSL_List(); } SetFlexi(part, flexi, softness, gravity, friction, wind, tension, force); break; case ScriptBaseClass.PRIM_POINT_LIGHT: if (remain < 5) return new LSL_List(); bool light; LSL_Vector lightcolor; float intensity; float radius; float falloff; try { light = rules.GetLSLIntegerItem(idx++); } catch(InvalidCastException) { Error(originFunc, string.Format("Error running rule #{0} -> PRIM_POINT_LIGHT: arg #{1} - parameter 2 must be integer", rulesParsed, idx - idxStart - 1)); return new LSL_List(); } try { lightcolor = rules.GetVector3Item(idx++); } catch(InvalidCastException) { Error(originFunc, string.Format("Error running rule #{0} -> PRIM_POINT_LIGHT: arg #{1} - parameter 3 must be vector", rulesParsed, idx - idxStart - 1)); return new LSL_List(); } try { intensity = (float)rules.GetLSLFloatItem(idx++); } catch(InvalidCastException) { Error(originFunc, string.Format("Error running rule #{0} -> PRIM_POINT_LIGHT: arg #{1} - parameter 4 must be float", rulesParsed, idx - idxStart - 1)); return new LSL_List(); } try { radius = (float)rules.GetLSLFloatItem(idx++); } catch(InvalidCastException) { Error(originFunc, string.Format("Error running rule #{0} -> PRIM_POINT_LIGHT: arg #{1} - parameter 5 must be float", rulesParsed, idx - idxStart - 1)); return new LSL_List(); } try { falloff = (float)rules.GetLSLFloatItem(idx++); } catch(InvalidCastException) { Error(originFunc, string.Format("Error running rule #{0} -> PRIM_POINT_LIGHT: arg #{1} - parameter 6 must be float", rulesParsed, idx - idxStart - 1)); return new LSL_List(); } SetPointLight(part, light, lightcolor, intensity, radius, falloff); break; case ScriptBaseClass.PRIM_GLOW: if (remain < 2) return new LSL_List(); float glow; try { face = rules.GetLSLIntegerItem(idx++); } catch(InvalidCastException) { Error(originFunc, string.Format("Error running rule #{0} -> PRIM_GLOW: arg #{1} - parameter 2 must be integer", rulesParsed, idx - idxStart - 1)); return new LSL_List(); } try { glow = (float)rules.GetLSLFloatItem(idx++); } catch(InvalidCastException) { Error(originFunc, string.Format("Error running rule #{0} -> PRIM_GLOW: arg #{1} - parameter 3 must be float", rulesParsed, idx - idxStart - 1)); return new LSL_List(); } SetGlow(part, face, glow); break; case ScriptBaseClass.PRIM_BUMP_SHINY: if (remain < 3) return new LSL_List(); int shiny; Bumpiness bump; try { face = (int)rules.GetLSLIntegerItem(idx++); } catch(InvalidCastException) { Error(originFunc, string.Format("Error running rule #{0} -> PRIM_BUMP_SHINY: arg #{1} - parameter 2 must be integer", rulesParsed, idx - idxStart - 1)); return new LSL_List(); } try { shiny = (int)rules.GetLSLIntegerItem(idx++); } catch(InvalidCastException) { Error(originFunc, string.Format("Error running rule #{0} -> PRIM_BUMP_SHINY: arg #{1} - parameter 3 must be integer", rulesParsed, idx - idxStart - 1)); return new LSL_List(); } try { bump = (Bumpiness)(int)rules.GetLSLIntegerItem(idx++); } catch(InvalidCastException) { Error(originFunc, string.Format("Error running rule #{0} -> PRIM_BUMP_SHINY: arg #{1} - parameter 4 must be integer", rulesParsed, idx - idxStart - 1)); return new LSL_List(); } SetShiny(part, face, shiny, bump); break; case ScriptBaseClass.PRIM_FULLBRIGHT: if (remain < 2) return new LSL_List(); bool st; try { face = rules.GetLSLIntegerItem(idx++); } catch(InvalidCastException) { Error(originFunc, string.Format("Error running rule #{0} -> PRIM_FULLBRIGHT: arg #{1} - parameter 2 must be integer", rulesParsed, idx - idxStart - 1)); return new LSL_List(); } try { st = rules.GetLSLIntegerItem(idx++); } catch(InvalidCastException) { Error(originFunc, string.Format("Error running rule #{0} -> PRIM_FULLBRIGHT: arg #{1} - parameter 4 must be integer", rulesParsed, idx - idxStart - 1)); return new LSL_List(); } SetFullBright(part, face , st); break; case ScriptBaseClass.PRIM_MATERIAL: if (remain < 1) return new LSL_List(); int mat; try { mat = rules.GetLSLIntegerItem(idx++); } catch(InvalidCastException) { Error(originFunc, string.Format("Error running rule #{0} -> PRIM_MATERIAL: arg #{1} - parameter 2 must be integer", rulesParsed, idx - idxStart - 1)); return new LSL_List(); } if (mat < 0 || mat > 7) return new LSL_List(); part.Material = Convert.ToByte(mat); break; case ScriptBaseClass.PRIM_PHANTOM: if (remain < 1) return new LSL_List(); string ph = rules.Data[idx++].ToString(); part.ParentGroup.ScriptSetPhantomStatus(ph.Equals("1")); break; case ScriptBaseClass.PRIM_PHYSICS: if (remain < 1) return new LSL_List(); string phy = rules.Data[idx++].ToString(); part.ScriptSetPhysicsStatus(phy.Equals("1")); break; case ScriptBaseClass.PRIM_PHYSICS_SHAPE_TYPE: if (remain < 1) return new LSL_List(); int shape_type; try { shape_type = rules.GetLSLIntegerItem(idx++); } catch(InvalidCastException) { Error(originFunc, string.Format("Error running rule #{0} -> PRIM_PHYSICS_SHAPE_TYPE: arg #{1} - parameter 2 must be integer", rulesParsed, idx - idxStart - 1)); return new LSL_List(); } ExtraPhysicsData physdata = new ExtraPhysicsData(); physdata.Density = part.Density; physdata.Bounce = part.Restitution; physdata.GravitationModifier = part.GravityModifier; physdata.PhysShapeType = (PhysShapeType)shape_type; part.UpdateExtraPhysics(physdata); break; case ScriptBaseClass.PRIM_TEMP_ON_REZ: if (remain < 1) return new LSL_List(); string temp = rules.Data[idx++].ToString(); part.ParentGroup.ScriptSetTemporaryStatus(temp.Equals("1")); break; case ScriptBaseClass.PRIM_TEXGEN: if (remain < 2) return new LSL_List(); //face,type int style; try { face = rules.GetLSLIntegerItem(idx++); } catch(InvalidCastException) { Error(originFunc, string.Format("Error running rule #{0} -> PRIM_TEXGEN: arg #{1} - parameter 2 must be integer", rulesParsed, idx - idxStart - 1)); return new LSL_List(); } try { style = rules.GetLSLIntegerItem(idx++); } catch(InvalidCastException) { Error(originFunc, string.Format("Error running rule #{0} -> PRIM_TEXGEN: arg #{1} - parameter 3 must be integer", rulesParsed, idx - idxStart - 1)); return new LSL_List(); } SetTexGen(part, face, style); break; case ScriptBaseClass.PRIM_TEXT: if (remain < 3) return new LSL_List(); string primText; LSL_Vector primTextColor; LSL_Float primTextAlpha; try { primText = rules.GetLSLStringItem(idx++); } catch(InvalidCastException) { Error(originFunc, string.Format("Error running rule #{0} -> PRIM_TEXT: arg #{1} - parameter 2 must be string", rulesParsed, idx - idxStart - 1)); return new LSL_List(); } try { primTextColor = rules.GetVector3Item(idx++); } catch(InvalidCastException) { Error(originFunc, string.Format("Error running rule #{0} -> PRIM_TEXT: arg #{1} - parameter 3 must be vector", rulesParsed, idx - idxStart - 1)); return new LSL_List(); } try { primTextAlpha = rules.GetLSLFloatItem(idx++); } catch(InvalidCastException) { Error(originFunc, string.Format("Error running rule #{0} -> PRIM_TEXT: arg #{1} - parameter 4 must be float", rulesParsed, idx - idxStart - 1)); return new LSL_List(); } Vector3 av3 = Util.Clip(primTextColor, 0.0f, 1.0f); part.SetText(primText, av3, Util.Clip((float)primTextAlpha, 0.0f, 1.0f)); break; case ScriptBaseClass.PRIM_NAME: if (remain < 1) return new LSL_List(); try { string primName = rules.GetLSLStringItem(idx++); part.Name = primName; } catch(InvalidCastException) { Error(originFunc, string.Format("Error running rule #{0} -> PRIM_NAME: arg #{1} - parameter 2 must be string", rulesParsed, idx - idxStart - 1)); return new LSL_List(); } break; case ScriptBaseClass.PRIM_DESC: if (remain < 1) return new LSL_List(); try { string primDesc = rules.GetLSLStringItem(idx++); part.Description = primDesc; } catch(InvalidCastException) { Error(originFunc, string.Format("Error running rule #{0} -> PRIM_DESC: arg #{1} - parameter 2 must be string", rulesParsed, idx - idxStart - 1)); return new LSL_List(); } break; case ScriptBaseClass.PRIM_ROT_LOCAL: if (remain < 1) return new LSL_List(); LSL_Rotation rot; try { rot = rules.GetQuaternionItem(idx++); } catch(InvalidCastException) { Error(originFunc, string.Format("Error running rule #{0} -> PRIM_ROT_LOCAL: arg #{1} - parameter 2 must be rotation", rulesParsed, idx - idxStart - 1)); return new LSL_List(); } SetRot(part, rot); break; case ScriptBaseClass.PRIM_OMEGA: if (remain < 3) return new LSL_List(); LSL_Vector axis; LSL_Float spinrate; LSL_Float gain; try { axis = rules.GetVector3Item(idx++); } catch(InvalidCastException) { Error(originFunc, string.Format("Error running rule #{0} -> PRIM_OMEGA: arg #{1} - parameter 2 must be vector", rulesParsed, idx - idxStart - 1)); return new LSL_List(); } try { spinrate = rules.GetLSLFloatItem(idx++); } catch(InvalidCastException) { Error(originFunc, string.Format("Error running rule #{0} -> PRIM_OMEGA: arg #{1} - parameter 3 must be float", rulesParsed, idx - idxStart - 1)); return new LSL_List(); } try { gain = rules.GetLSLFloatItem(idx++); } catch(InvalidCastException) { Error(originFunc, string.Format("Error running rule #{0} -> PRIM_OMEGA: arg #{1} - parameter 4 must be float", rulesParsed, idx - idxStart - 1)); return new LSL_List(); } TargetOmega(part, axis, (double)spinrate, (double)gain); break; case ScriptBaseClass.PRIM_SLICE: if (remain < 1) return new LSL_List(); LSL_Vector slice; try { slice = rules.GetVector3Item(idx++); } catch(InvalidCastException) { Error(originFunc, string.Format("Error running rule #{0} -> PRIM_SLICE: arg #{1} - parameter 2 must be vector", rulesParsed, idx - idxStart - 1)); return new LSL_List(); } part.UpdateSlice((float)slice.x, (float)slice.y); break; case ScriptBaseClass.PRIM_LINK_TARGET: if (remain < 3) // setting to 3 on the basis that parsing any usage of PRIM_LINK_TARGET that has nothing following it is pointless. return new LSL_List(); return rules.GetSublist(idx, -1); default: Error(originFunc, string.Format("Error running rule #{0}: arg #{1} - unsupported parameter", rulesParsed, idx - idxStart)); return new LSL_List(); } } } catch (InvalidCastException e) { Error(originFunc, string.Format("Error running rule #{0}: arg #{1} - ", rulesParsed, idx - idxStart) + e.Message); } finally { if (positionChanged) { if (part.ParentGroup.RootPart == part) { SceneObjectGroup parent = part.ParentGroup; parent.UpdateGroupPosition(currentPosition); } else { part.OffsetPosition = currentPosition; SceneObjectGroup parent = part.ParentGroup; parent.HasGroupChanged = true; parent.ScheduleGroupForTerseUpdate(); } } } return new LSL_List(); }
protected LSL_List SetPrimParams(ScenePresence av, LSL_List rules, string originFunc, ref uint rulesParsed) { //This is a special version of SetPrimParams to deal with avatars which are sitting on the linkset. int idx = 0; int idxStart = 0; bool positionChanged = false; try { while (idx < rules.Length) { ++rulesParsed; int code = rules.GetLSLIntegerItem(idx++); int remain = rules.Length - idx; idxStart = idx; switch (code) { case (int)ScriptBaseClass.PRIM_POSITION: case (int)ScriptBaseClass.PRIM_POS_LOCAL: { if (remain < 1) return new LSL_List(); LSL_Vector v; v = rules.GetVector3Item(idx++); if(!av.LegacySitOffsets) { LSL_Vector sitOffset = (llRot2Up(new LSL_Rotation(av.Rotation.X, av.Rotation.Y, av.Rotation.Z, av.Rotation.W)) * av.Appearance.AvatarHeight * 0.02638f); v = v + 2 * sitOffset; } av.OffsetPosition = new Vector3((float)v.x, (float)v.y, (float)v.z); positionChanged = true; } break; case (int)ScriptBaseClass.PRIM_ROTATION: { if (remain < 1) return new LSL_List(); Quaternion r; r = rules.GetQuaternionItem(idx++); av.Rotation = m_host.GetWorldRotation() * r; positionChanged = true; } break; case (int)ScriptBaseClass.PRIM_ROT_LOCAL: { if (remain < 1) return new LSL_List(); LSL_Rotation r; r = rules.GetQuaternionItem(idx++); av.Rotation = r; positionChanged = true; } break; // parse rest doing nothing but number of parameters error check case (int)ScriptBaseClass.PRIM_SIZE: case (int)ScriptBaseClass.PRIM_MATERIAL: case (int)ScriptBaseClass.PRIM_PHANTOM: case (int)ScriptBaseClass.PRIM_PHYSICS: case (int)ScriptBaseClass.PRIM_PHYSICS_SHAPE_TYPE: case (int)ScriptBaseClass.PRIM_TEMP_ON_REZ: case (int)ScriptBaseClass.PRIM_NAME: case (int)ScriptBaseClass.PRIM_DESC: if (remain < 1) return new LSL_List(); idx++; break; case (int)ScriptBaseClass.PRIM_GLOW: case (int)ScriptBaseClass.PRIM_FULLBRIGHT: case (int)ScriptBaseClass.PRIM_TEXGEN: if (remain < 2) return new LSL_List(); idx += 2; break; case (int)ScriptBaseClass.PRIM_TYPE: if (remain < 3) return new LSL_List(); code = (int)rules.GetLSLIntegerItem(idx++); remain = rules.Length - idx; switch (code) { case (int)ScriptBaseClass.PRIM_TYPE_BOX: case (int)ScriptBaseClass.PRIM_TYPE_CYLINDER: case (int)ScriptBaseClass.PRIM_TYPE_PRISM: if (remain < 6) return new LSL_List(); idx += 6; break; case (int)ScriptBaseClass.PRIM_TYPE_SPHERE: if (remain < 5) return new LSL_List(); idx += 5; break; case (int)ScriptBaseClass.PRIM_TYPE_TORUS: case (int)ScriptBaseClass.PRIM_TYPE_TUBE: case (int)ScriptBaseClass.PRIM_TYPE_RING: if (remain < 11) return new LSL_List(); idx += 11; break; case (int)ScriptBaseClass.PRIM_TYPE_SCULPT: if (remain < 2) return new LSL_List(); idx += 2; break; } break; case (int)ScriptBaseClass.PRIM_COLOR: case (int)ScriptBaseClass.PRIM_TEXT: case (int)ScriptBaseClass.PRIM_BUMP_SHINY: case (int)ScriptBaseClass.PRIM_OMEGA: if (remain < 3) return new LSL_List(); idx += 3; break; case (int)ScriptBaseClass.PRIM_TEXTURE: case (int)ScriptBaseClass.PRIM_POINT_LIGHT: case (int)ScriptBaseClass.PRIM_PHYSICS_MATERIAL: if (remain < 5) return new LSL_List(); idx += 5; break; case (int)ScriptBaseClass.PRIM_FLEXIBLE: if (remain < 7) return new LSL_List(); idx += 7; break; case (int)ScriptBaseClass.PRIM_LINK_TARGET: if (remain < 3) // setting to 3 on the basis that parsing any usage of PRIM_LINK_TARGET that has nothing following it is pointless. return new LSL_List(); return rules.GetSublist(idx, -1); } } } catch (InvalidCastException e) { Error(originFunc,string.Format( " error running rule #{1}: arg #{2} ", rulesParsed, idx - idxStart) + e.Message); } finally { if (positionChanged) av.SendTerseUpdateToAllClients(); } return new LSL_List(); }