Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- /// Whip's Battle Light Script v1 - revision 3/10/16 ///
- /////INSTRUCTIONS/////
- =====ARGUMENTS=====
- Run this program with the following arguments to do the described functions
- alarm on: switches light colors to alarm state
- alarm off: switches light colors to default state
- alarm toggle: toggles alarm state
- =====NAMING=====
- Name alarm lights like the following:
- <your light name> <standard color> [Alarm] <alarm state>
- Accepted <colors>:
- [Brown] and [Purple]
- Accepted <alarm states>:
- [Off] and empty
- Examples: To make a light named "Swag Light 4" change its color from purple the alarm
- state color you'd name it:
- Swag Light 4 [Purple] [Alarm]
- To make the alarm light turn off when in alarmed state you'd instead name it:
- Swag Light 4 [Purple] [Alarm] [Off]
- /////NOTES/////
- Script by Whiplash141 at the request of WTFFSwan :)
- */
- //Name tag to denote all alarm lights
- const string strAlarmTag = "[Alarm]";
- //-----------------------------------------------------
- //pick one of these to put in the name of the light
- const string strStandardColor1 = "[Purple]";
- const string strStandardColor2 = "[Brown]";
- //-----------------------------------------------------
- const string strLightOff = "[Off]"; //only add this into the block name if you want to
- //switch it off in alarm state
- //make our colors
- Color colorStandard1 = new Color( 29, 22, 35 ); //purple
- Color colorStandard2 = new Color( 178, 131, 86 ); //brownish
- Color colorAlarm = new Color( 200, 50, 50 );
- //======================================
- //Don't touch anything below this!
- //======================================
- bool alarmIsOn = false;
- List <IMyTerminalBlock> listAlarmLights = new List<IMyTerminalBlock>();
- void Main( string arg )
- {
- Echo( "WMI Battle Light Script" );
- switch( arg.ToLower() )
- {
- case "alarm on":
- alarmIsOn = true;
- Echo( "Alarm state toggled on" );
- break;
- case "alarm off":
- alarmIsOn = false;
- Echo( "Alarm state toggled off" );
- break;
- case "alarm toggle":
- if( alarmIsOn )
- {
- alarmIsOn = false;
- Echo( "Alarm state toggled off" );
- }else{
- alarmIsOn = true;
- Echo( "Alarm state toggled on" );
- }
- break;
- default:
- Echo("No valid arguments detected, see top of code for accepted arguments");
- break;
- }
- //get our alarm lights
- GridTerminalSystem.SearchBlocksOfName( strAlarmTag, listAlarmLights, isLight );
- //go through each light and apply colors
- for( int i = 0; i < listAlarmLights.Count; i++ )
- {
- var thisLight = listAlarmLights[i] as IMyLightingBlock;
- if( alarmIsOn )
- {
- if( !thisLight.CustomName.Contains( strLightOff ) )
- {
- thisLight.SetValue( "Color", colorAlarm );
- }else{
- if( thisLight.GetValue<bool>( "OnOff" ) == true )
- {
- thisLight.ApplyAction( "OnOff_Off" );
- }
- }
- }else{
- if( thisLight.CustomName.Contains( strStandardColor1 ) )
- {
- thisLight.SetValue( "Color", colorStandard1 );
- }
- else if( thisLight.CustomName.Contains( strStandardColor2 ) )
- {
- thisLight.SetValue( "Color", colorStandard2 );
- }
- if( thisLight.GetValue<bool>( "OnOff" ) == false )
- {
- thisLight.ApplyAction( "OnOff_On" );
- }
- }
- }
- }
- bool isLight( IMyTerminalBlock block )
- {
- var lightTest = block as IMyLightingBlock;
- return lightTest != null;
- }
Advertisement
Add Comment
Please, Sign In to add comment