Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Whip's Missile Renamer v1 - 3/24/16
- //You can change these variables
- const int missileNumber = 1;
- const string strMissileName = "Missile";
- //----------------------------------------------------
- //Dont touch below this
- //----------------------------------------------------
- string strMissileTag = strMissileName + " " + missileNumber;
- void Main()
- {
- var listBlocks = new List<IMyTerminalBlock>();
- var listGyros = new List<IMyTerminalBlock>();
- GridTerminalSystem.GetBlocks( listBlocks );
- GridTerminalSystem.GetBlocksOfType<IMyGyro>( listGyros );
- bool referencePresent = listGyros.Count != 0;
- for( int i = 0; i < listBlocks.Count; i++ )
- {
- var thisBlock = listBlocks[i] as IMyTerminalBlock;
- string strBlockType = "";
- string strThrusterModifier = "";
- //comb through all blocks and rename
- if( thisBlock is IMyThrust )
- {
- //check if small or large thruster
- if( thisBlock.CustomName.ToLower().Contains( "small" ) )
- {
- strBlockType = "Small Thruster";
- }
- else if( thisBlock.CustomName.ToLower().Contains( "large" ) )
- {
- strBlockType = "Large Thruster";
- }else{
- strBlockType = "Thruster";
- }
- //check the orientation of the thruster and name it accordingly
- if( referencePresent )
- {
- var thrusterDirection = thisBlock.WorldMatrix.Backward; //because backward thrust = forward motion
- var referenceBlock = listGyros[0];
- var referenceDirection = referenceBlock.WorldMatrix.Forward;
- if( thrusterDirection == referenceDirection ) //w.H.i.p.l.a.s.H.1.4.1
- {
- strThrusterModifier = " Main";
- }else{
- strThrusterModifier = " Side";
- }
- }
- }
- else if( thisBlock is IMyVirtualMass )
- {
- strBlockType = "Artificial Mass";
- }
- else if( thisBlock is IMyBatteryBlock )
- {
- strBlockType = "Battery";
- }
- else if( thisBlock is IMyGyro )
- {
- strBlockType = "Gyroscope";
- }
- else if( thisBlock is IMyShipMergeBlock )
- {
- strBlockType = "Merge Block";
- }
- else if( thisBlock is IMyTimerBlock )
- {
- strBlockType = "Gyroscope";
- }
- else if( thisBlock is IMyProgrammableBlock )
- {
- strBlockType = "Program";
- }
- else if( thisBlock is IMyRemoteControl )
- {
- strBlockType = "Remote";
- }else{
- return;
- }
- //apply new name to the block
- string strBlockName = strBlockType + strThrusterModifier + " (" + strMissileTag + ")";
- thisBlock.SetCustomName( strBlockName );
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement