Advertisement
Whiplash141

Whip's Wheel Displacement Toggler

Mar 8th, 2016
141
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.84 KB | None | 0 0
  1.  
  2. /*
  3. =========================================================
  4. Whip's Wheel Height Toggler v1 - Revision: 11/30/15
  5. =========================================================
  6.  
  7. ACCEPTED ARGUMENTS:
  8.  
  9. Max : Sets Height to maximum
  10. Min : Sets Height to minimum
  11. <number> : sets Height to the input number in centimeters
  12.  
  13.  
  14. Written by Whiplash141
  15. */
  16.  
  17. string strWheelName = "This Wheel";
  18.  
  19. float floatValue;
  20. bool isNumber = false;
  21. List<IMyTerminalBlock> wheels = new List<IMyTerminalBlock>();
  22.  
  23. void Main( string arg )
  24. {
  25.     var gts = GridTerminalSystem;//I just wanted to see if this works ;)
  26.     gts.SearchBlocksOfName( strWheelName, wheels );
  27.    
  28.     isNumber = float.TryParse( arg, out floatValue );
  29.     if( isNumber )
  30.     {
  31.         Echo("Float Input: " + floatValue + " cm" );
  32.         FloatDisplacement( floatValue / 100 );
  33.     }
  34.     else if( arg.ToLower() == "max" )
  35.     {
  36.         MaxDisplacement();
  37.         Echo("Set Max Height" );
  38.     }
  39.     else if( arg.ToLower() == "min" )
  40.     {
  41.         MinDisplacement();
  42.         Echo("Set Min Height" );
  43.     }else{
  44.         Echo("No valid inputs\n\nSee the code for input parameters");
  45.     }
  46. }
  47.  
  48. void MaxDisplacement()
  49. {
  50.     for( int i = 0; i < wheels.Count; i++ )
  51.     {
  52.         var thisBlock = wheels[i] as IMyMotorSuspension;
  53.         if( thisBlock != null ) thisBlock.SetValue<float>("Height", float.MaxValue);
  54.     }
  55. }
  56.  
  57. void MinDisplacement()
  58. {
  59.     for( int i = 0; i < wheels.Count; i++ )
  60.     {
  61.         var thisBlock = wheels[i] as IMyMotorSuspension;
  62.         if( thisBlock != null ) thisBlock.SetValue<float>("Height", float.MinValue);
  63.     }
  64. }
  65.  
  66. void FloatDisplacement( float value )
  67. {
  68.     for( int i = 0; i < wheels.Count; i++ )
  69.     {
  70.         var thisBlock = wheels[i] as IMyMotorSuspension;
  71.         if( thisBlock != null ) thisBlock.SetValue<float>("Height", value );
  72.     }
  73. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement