Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- ==============================================
- Whip's Battery Recharge Toggler v3 - 12/23/15
- ==============================================
- INSTRUCTIONS:
- Enter the following into the programs argument then run it:
- <command>;<block name>
- <command> can be either "toggle", "recharge", or "discharge" (without quotes)
- <bock name> is the name of the battery that you wish to mess with
- EXAMPLES:
- Say I wanted to make a battery named "Battery - Torpedo" recharge.
- We would enter:
- recharge;Battery - Torpedo
- if we want to discharge we would put:
- discharge;Battery - Torpedo
- if we wanted to just toggle the current state we would put:
- toggle;Battery - Torpedo
- OTHER:
- Feel free to shoot me any questions
- - Whiplash141 - https://steamcommunity.com/id/Whiplash141/
- */
- /*
- ===================================
- Don't touch anything below this <3
- ===================================
- */
- List<IMyTerminalBlock> torpB = new List<IMyTerminalBlock>();
- void Main(string cmd)
- {
- string[] cmd_split = cmd.Split(';');
- if (cmd_split.Length > 1)
- {
- GridTerminalSystem.SearchBlocksOfName(cmd_split[1],torpB);
- switch(cmd_split[0].ToLower())
- {
- case "toggle":
- BattsToggle();
- Echo("Toggling batteries with name: " + cmd_split[1]);
- break;
- case "recharge":
- BattsRecharge();
- Echo("Recharging batteries with name: " + cmd_split[1]);
- break;
- case "discharge":
- BattsDischarge();
- Echo("Discharging batteries with name: " + cmd_split[1]);
- break;
- case default:
- Echo("No valid command entered");
- break;
- }
- }
- }
- void BattsToggle()
- {
- for(int j = 0; j < torpB.Count; j++)
- {
- if(torpB[j] is IMyBatteryBlock)
- {
- var torpBat = torpB[j] as IMyBatteryBlock;
- torpBat.GetActionWithName("Recharge").Apply(torpBat);
- }
- }
- }
- void BattsRecharge()
- {
- for(int j = 0; j < torpB.Count; j++)
- {
- if(torpB[j] is IMyBatteryBlock)
- {
- var torpBat = torpB[j] as IMyBatteryBlock;
- torpBat.SetValue("Recharge", true);
- }
- }
- }
- void BattsDischarge()
- {
- for(int j = 0; j < torpB.Count; j++)
- {
- if(torpB[j] is IMyBatteryBlock)
- {
- var torpBat = torpB[j] as IMyBatteryBlock;
- torpBat.SetValue("Recharge", false);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment