Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- Whip's Decoy Alternator v4 - 10/21/15
- */
- List<IMyTerminalBlock> decoys = new List<IMyTerminalBlock>();
- string decoyName = "Decoy";
- int currentTick = 1;
- int tickLimit = 15;
- int currentCount = 0;
- bool toggleOn = true; //default state of the alternator
- bool defaultOn = false; //change this if you want the decoys to default to on when not being alternated
- void Main (string arg)
- {
- switch(arg.ToLower())
- {
- case "on":
- toggleOn = true;
- break;
- case "off":
- toggleOn = false;
- break;
- case "toggle":
- if (toggleOn)
- {
- toggleOn = false;
- }
- else
- {
- toggleOn = true;
- }
- break;
- default:
- break;
- }
- GridTerminalSystem.SearchBlocksOfName(decoyName,decoys);
- if (currentTick % tickLimit == 0)
- {
- for (int i=0 ; i < decoys.Count ; i++)
- {
- var thisDecoy = decoys[i] as IMyTerminalBlock;
- thisDecoy.ApplyAction("OnOff_Off");
- if (!toggleOn)
- {
- if(defaultOn)
- {
- thisDecoy.ApplyAction("OnOff_On");
- }
- }
- }
- if(currentCount < decoys.Count-1)
- {
- currentCount++;
- }
- else
- {
- currentCount = 0;
- }
- currentTick = 0;
- if(toggleOn)
- {
- decoys[currentCount].ApplyAction("OnOff_On");
- }
- }
- currentTick++;
- if(toggleOn)
- {
- Echo("--Alternator On--");
- }
- else
- {
- Echo("--Alternator Off--");
- }
- Echo("Current Tick: " + currentTick);
- Echo("Tick Limit: " + tickLimit);
- Echo("No. Decoys: " + decoys.Count);
- Echo("Current Decoy: " + (currentCount + 1));
- }
Advertisement
Add Comment
Please, Sign In to add comment