Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- int long_count = 0;
- int deep_count = 0;
- void Main(string argument)
- {
- // block declarations
- string ERR_TXT = "";
- List<IMyTerminalBlock> l4 = new List<IMyTerminalBlock>();
- IMyShipDrill v4 = null;
- GridTerminalSystem.GetBlocksOfType<IMyShipDrill>(l4);
- if(l4.Count == 0) {
- ERR_TXT += "no Drill blocks found\n";
- }
- else {
- for(int i = 0; i < l4.Count; i++) {
- if(l4[i].CustomName == "mining_drill") {
- v4 = (IMyShipDrill)l4[i];
- break;
- }
- }
- if(v4 == null) {
- ERR_TXT += "no Drill block named mining_drill found\n";
- }
- }
- List<IMyTerminalBlock> l5 = new List<IMyTerminalBlock>();
- IMyMotorAdvancedStator v5 = null;
- GridTerminalSystem.GetBlocksOfType<IMyMotorAdvancedStator>(l5);
- if(l5.Count == 0) {
- ERR_TXT += "no Advanced Rotor blocks found\n";
- }
- else {
- for(int i = 0; i < l5.Count; i++) {
- if(l5[i].CustomName == "mining_angle") {
- v5 = (IMyMotorAdvancedStator)l5[i];
- break;
- }
- }
- if(v5 == null) {
- ERR_TXT += "no Advanced Rotor block named mining_angle found\n";
- }
- }
- List<IMyTerminalBlock> v6 = new List<IMyTerminalBlock>();
- GridTerminalSystem.GetBlocksOfType<IMyPistonBase>(v6);
- if(v6.Count == 0) {
- ERR_TXT += "no Piston blocks found\n";
- }
- List<IMyTerminalBlock> v9 = new List<IMyTerminalBlock>();
- if(GridTerminalSystem.GetBlockGroupWithName("mining_refinery") != null) {
- GridTerminalSystem.GetBlockGroupWithName("mining_refinery").GetBlocksOfType<IMyRefinery>(v9);
- if(v9.Count == 0) {
- ERR_TXT += "group mining_refinery has no Refinery blocks\n";
- }
- }
- else {
- ERR_TXT += "group mining_refinery not found\n";
- }
- List<IMyTerminalBlock> l12 = new List<IMyTerminalBlock>();
- IMyPistonBase v12 = null;
- GridTerminalSystem.GetBlocksOfType<IMyPistonBase>(l12);
- if(l12.Count == 0) {
- ERR_TXT += "no Piston blocks found\n";
- }
- else {
- for(int i = 0; i < l12.Count; i++) {
- if(l12[i].CustomName == "mining_long") {
- v12 = (IMyPistonBase)l12[i];
- break;
- }
- }
- if(v12 == null) {
- ERR_TXT += "no Piston block named mining_long found\n";
- }
- }
- List<IMyTerminalBlock> v17 = new List<IMyTerminalBlock>();
- if(GridTerminalSystem.GetBlockGroupWithName("mining_deep_pistons") != null) {
- GridTerminalSystem.GetBlockGroupWithName("mining_deep_pistons").GetBlocksOfType<IMyPistonBase>(v17);
- if(v17.Count == 0) {
- ERR_TXT += "group mining_deep_pistons has no Piston blocks\n";
- }
- }
- else {
- ERR_TXT += "group mining_deep_pistons not found\n";
- }
- // display errors
- if(ERR_TXT != "") {
- Echo("Script Errors:\n"+ERR_TXT+"(make sure block ownership is set correctly)");
- return;
- }
- else {Echo("");}
- // logic
- if(getDegrees(v5.Angle) > 84 || (getDegrees(v5.Angle) < 276)) {
- v5.ApplyAction("Reverse");
- long_count = long_count+1;
- }
- }
- const string MULTIPLIERS = ".kMGTPEZY";
- float getExtraFieldFloat(IMyTerminalBlock block, string regexString) {
- System.Text.RegularExpressions.Regex regex = new System.Text.RegularExpressions.Regex(regexString, System.Text.RegularExpressions.RegexOptions.Singleline);
- float result = 0.0f;
- double parsedDouble;
- System.Text.RegularExpressions.Match match = regex.Match(block.DetailedInfo);
- if (match.Success) {
- if (Double.TryParse(match.Groups[1].Value, out parsedDouble)) {
- result = (float) parsedDouble;
- }
- if(MULTIPLIERS.IndexOf(match.Groups[2].Value) > -1) {
- result = result * (float) Math.Pow(1000.0, MULTIPLIERS.IndexOf(match.Groups[2].Value));
- }
- }
- return result;
- }
- float getDegrees(float rad) {
- return (float) (rad * (180/Math.PI));
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement