Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- =========================================================
- Whip's Wheel Height Toggler v1 - Revision: 11/30/15
- =========================================================
- ACCEPTED ARGUMENTS:
- Max : Sets Height to maximum
- Min : Sets Height to minimum
- <number> : sets Height to the input number in centimeters
- Written by Whiplash141
- */
- string strWheelName = "This Wheel";
- float floatValue;
- bool isNumber = false;
- List<IMyTerminalBlock> wheels = new List<IMyTerminalBlock>();
- void Main( string arg )
- {
- var gts = GridTerminalSystem;//I just wanted to see if this works ;)
- gts.SearchBlocksOfName( strWheelName, wheels );
- isNumber = float.TryParse( arg, out floatValue );
- if( isNumber )
- {
- Echo("Float Input: " + floatValue + " cm" );
- FloatDisplacement( floatValue / 100 );
- }
- else if( arg.ToLower() == "max" )
- {
- MaxDisplacement();
- Echo("Set Max Height" );
- }
- else if( arg.ToLower() == "min" )
- {
- MinDisplacement();
- Echo("Set Min Height" );
- }else{
- Echo("No valid inputs\n\nSee the code for input parameters");
- }
- }
- void MaxDisplacement()
- {
- for( int i = 0; i < wheels.Count; i++ )
- {
- var thisBlock = wheels[i] as IMyMotorSuspension;
- if( thisBlock != null ) thisBlock.SetValue<float>("Height", float.MaxValue);
- }
- }
- void MinDisplacement()
- {
- for( int i = 0; i < wheels.Count; i++ )
- {
- var thisBlock = wheels[i] as IMyMotorSuspension;
- if( thisBlock != null ) thisBlock.SetValue<float>("Height", float.MinValue);
- }
- }
- void FloatDisplacement( float value )
- {
- for( int i = 0; i < wheels.Count; i++ )
- {
- var thisBlock = wheels[i] as IMyMotorSuspension;
- if( thisBlock != null ) thisBlock.SetValue<float>("Height", value );
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement