Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- diff --git a/Data/Scripts/EvilSensor/EvilSensor.cs b/Data/Scripts/EvilSensor/EvilSensor.cs
- index e851c4d..8e43484 100644
- --- a/Data/Scripts/EvilSensor/EvilSensor.cs
- +++ b/Data/Scripts/EvilSensor/EvilSensor.cs
- @@ -100,21 +100,20 @@ void sensor_StateChanged(bool obj)
- // !obj would be when you exited the range, so nothing happens.
- if (!obj) return;
- - // Define some mo' variables
- - string objectName = "Iron";
- -
- - string spawnType = "Ore";
- -
- string sensorName = Sensor.CustomName;
- - VRageMath.Vector3 direction = Sensor.WorldMatrix.Forward;
- + if (sensorName.Contains("[") && sensorName.Contains("]"))
- + {
- + // Define some mo' variables
- + string objectName = "Iron";
- - var amount = 100;
- + string spawnType = "Ore";
- - var distance = 1.5f;
- + VRageMath.Vector3 direction = Sensor.WorldMatrix.Forward;
- - if (sensorName.Contains("[") && sensorName.Contains("]"))
- - {
- + var amount = 100;
- +
- + var distance = 1.5f;
- /*
- * At this point, we parse the "data string" from the name,
- * break it down into sections, see what tags those sections
- @@ -273,39 +272,39 @@ void sensor_StateChanged(bool obj)
- direction = Sensor.WorldMatrix.Forward;
- Logging.Instance.WriteLine(String.Format("sensor_StateChanged(), String Parser: {0}", ex.ToString()));
- }
- - }
- - try
- - {
- - // Create the object to be spawned
- - MyObjectBuilder_FloatingObject floatingBuilder = new MyObjectBuilder_FloatingObject();
- + try
- + {
- + // Create the object to be spawned
- + MyObjectBuilder_FloatingObject floatingBuilder = new MyObjectBuilder_FloatingObject();
- - floatingBuilder.PersistentFlags = MyPersistentEntityFlags2.InScene; // Very important, but I'm not sure why. I guess if not flagged as InScene, it won't be recognized as actually being there would be my guess.
- + floatingBuilder.PersistentFlags = MyPersistentEntityFlags2.InScene; // Very important, but I'm not sure why. I guess if not flagged as InScene, it won't be recognized as actually being there would be my guess.
- - // Set the postition and orientation of the object in the world.
- - floatingBuilder.PositionAndOrientation = new MyPositionAndOrientation(Sensor.WorldMatrix.Translation + direction * distance, Sensor.WorldMatrix.Forward, Sensor.WorldMatrix.Up);
- + // Set the postition and orientation of the object in the world.
- + floatingBuilder.PositionAndOrientation = new MyPositionAndOrientation(Sensor.WorldMatrix.Translation + direction * distance, Sensor.WorldMatrix.Forward, Sensor.WorldMatrix.Up);
- - // Specify that the object is an inventory item of the type and amount specified
- - switch (spawnType.ToLowerInvariant())
- + // Specify that the object is an inventory item of the type and amount specified
- + switch (spawnType.ToLowerInvariant())
- + {
- + case "component":
- + floatingBuilder.Item = new MyObjectBuilder_InventoryItem() { Amount = amount, Content = new MyObjectBuilder_Component { SubtypeName = objectName } };
- + break;
- + case "ingot":
- + floatingBuilder.Item = new MyObjectBuilder_InventoryItem() { Amount = amount, Content = new MyObjectBuilder_Ingot() { SubtypeName = objectName } };
- + break;
- + case "ore":
- + floatingBuilder.Item = new MyObjectBuilder_InventoryItem() { Amount = amount, Content = new MyObjectBuilder_Ore() { SubtypeName = objectName } };
- + break;
- + default:
- + break;
- + }
- +
- + // Finally, we actually create & spawn the damn thing in the world here. Enjoy!
- + var floatingObject = Sandbox.ModAPI.MyAPIGateway.Entities.CreateFromObjectBuilderAndAdd(floatingBuilder);
- + }
- + catch (Exception ex)
- {
- - case "component":
- - floatingBuilder.Item = new MyObjectBuilder_InventoryItem() { Amount = amount, Content = new MyObjectBuilder_Component { SubtypeName = objectName } };
- - break;
- - case "ingot":
- - floatingBuilder.Item = new MyObjectBuilder_InventoryItem() { Amount = amount, Content = new MyObjectBuilder_Ingot() { SubtypeName = objectName } };
- - break;
- - case "ore":
- - floatingBuilder.Item = new MyObjectBuilder_InventoryItem() { Amount = amount, Content = new MyObjectBuilder_Ore() { SubtypeName = objectName } };
- - break;
- - default:
- - break;
- + Logging.Instance.WriteLine(String.Format("sensor_StateChanged(), Object Builder: {0}", ex.ToString()));
- }
- -
- - // Finally, we actually create & spawn the damn thing in the world here. Enjoy!
- - var floatingObject = Sandbox.ModAPI.MyAPIGateway.Entities.CreateFromObjectBuilderAndAdd(floatingBuilder);
- - }
- - catch (Exception ex)
- - {
- - Logging.Instance.WriteLine(String.Format("sensor_StateChanged(), Object Builder: {0}", ex.ToString()));
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment