Advertisement
Whiplash141

Whip's Rangefinder for the GAW [SpaceEngineers]

Sep 21st, 2015
135
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.78 KB | None | 0 0
  1.  
  2. /*  
  3. /// Whip's Rangefinder Script v1.1 - 9/20/15 ///
  4. Made for the GAW Platform
  5.  
  6. */
  7.  
  8. string mergeName ="Merge - Type A (GAW1)"; //vector head
  9. string timerName = "Timer - Projectile Selecter (GAW1)"; //vector tail
  10. string projectorName = "Projector - Reticle Aperture (Right)";
  11. string rotorName = "Rotor - Reticle (Right) (GAW1)";
  12.  
  13. double projectorOffset;
  14. double rotorOffset;
  15.  
  16. void Main()
  17. {
  18.     var projector = GridTerminalSystem.GetBlockWithName(projectorName) as IMyProjector;
  19.     var rotor = GridTerminalSystem.GetBlockWithName(rotorName) as IMyMotorStator;
  20.     var shipVectorTail = GridTerminalSystem.GetBlockWithName(timerName);
  21.     var shipVectorHead = GridTerminalSystem.GetBlockWithName(mergeName);
  22.      
  23.     projectorOffset = (double)projector.ProjectionOffsetZ;
  24.     rotorOffset = (double)rotor.Displacement + .045; //.045 is rotor offset factor
  25.      
  26.     double A = 5;
  27.     double B = 5 + .5 * projectorOffset;
  28.     double C = 5 - rotorOffset;
  29.     double D = A-C; //XD double d's hehe... i need help
  30.      
  31.     if (D > 0)
  32.     {
  33.         double distance = A*B/D;
  34.         Echo("Distance: " + distance.ToString());
  35.     }else{
  36.         Echo("Distance: Infinity");
  37.     }
  38.      
  39.     Vector3D shipVectorHeadPos = new Vector3D(0, 0, 0);  
  40.     Vector3D shipVectorTailPos = new Vector3D(0, 0, 0);  
  41.     Vector3D shipVectorFinal = new Vector3D(0, 0, 0);  
  42.      
  43.     shipVectorHeadPos = shipVectorHead.GetPosition();
  44.     shipVectorTailPos = shipVectorTail.GetPosition();
  45.     shipVectorFinal = shipVectorHeadPos - shipVectorTailPos;
  46.         //cast distance onto this
  47.     Echo("\nVector: " + shipVectorFinal.ToString());
  48.     Echo("\n Projector Offset: " + projectorOffset.ToString());
  49.     Echo("\n Rotor Offset: " + rotorOffset.ToString());
  50.  
  51. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement