Whiplash141

Timber Wolf Torpedo Status Script - 7/26/15

Jul 26th, 2015
713
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 4.75 KB | None | 0 0
  1.  /*    
  2. ////Write Text To LCD v1.T//// - adapted for use in the Timber Wolf - 7/25/15 - Whiplash141  
  3.    
  4. DESCRIPTION:    
  5. This script will display the status of the Gladius' main guns onto    
  6. LCD readouts :)    
  7.    
  8. SETUP:    
  9. Run this script with the arguments below to update the screen status        
  10.    
  11. ARGUMENTS:  
  12. Arguments can be input manually via the control panel or saved and triggered on  
  13. demand via timers.  
  14. All these arguments should be entered without quotes!    
  15.    
  16. "Ready <Screen Number>"    
  17.     -Displays ARMED on the specified status LCD    
  18.        
  19. "Fire <Screen Number>"  
  20.     -Displays FIRING on the specified status LCD    
  21.    
  22. "Reload <Screen Number>"  
  23.     -Displays RELOADING on the specified status LCD  
  24.  
  25. "<Type> <Screen Number>"  
  26.  - K: Kinetic  
  27.  - HE: High Explosive  
  28.  - ECM: ECM  
  29.  - M: Mines  
  30.        
  31. EXAMPLES:  
  32. Argument:  |   Result:        
  33.   --------------|-------------------------------------------  
  34. "Fire 1"        |   Writes "Torpedo One: Firing" to LCD Panel - Round One    
  35. "reload 2"   |   Writes "Torpedo Two: Reloading" to LCD Panel - Round Two    
  36. "rEaDy 2"   |   Writes "Torpedo Two: Reloading" to LCD Panel - Round Two    
  37.    
  38. ***Note how letter case is not an issue :D (please don't type like that though...)***  
  39.     - Whiplash :)    
  40.  */    
  41.  
  42. string roundOnePanelName = "LCD Panel - Torpedo 1";    
  43. string roundTwoPanelName = "LCD Panel - Torpedo 2";    
  44. string panelToWrite;    
  45. string roundNumber = "null";  
  46. string roundStatus;  
  47. string roundStatus_1 = "Armed";
  48. string roundStatus_2 =  "Armed";
  49. string roundType;  
  50. string roundType_1 = "Kinetic";  
  51. string roundType_2 = "Kinetic";  
  52. string Message;  
  53. bool skip = true;
  54.  
  55. List<IMyTerminalBlock> textPanels = new List<IMyTerminalBlock>();    
  56.        
  57. void Main(string input)    
  58. {        
  59.     string input_lower = input.ToLower();    
  60.     string[] input_split = input_lower.Split(' ');            
  61.    
  62.     switch (input_split[0])  //primary argument  
  63.     {    
  64.         case "fire":    
  65.             roundStatus = "Firing    ";  
  66.             skip = false;
  67.             break;    
  68.                
  69.         case "reload":    
  70.             roundStatus = "Reloading";    
  71.             skip = false;
  72.             break;    
  73.    
  74.         case "ready":    
  75.             roundStatus = "Armed     ";    
  76.             skip = false;
  77.             break;    
  78.              
  79.         case "k":    
  80.             roundType = "Kinetic";  
  81.             skip = false;
  82.             break;  
  83.              
  84.         case "he":  
  85.             roundType = "High Explosive";  
  86.             skip = false;
  87.             break;  
  88.              
  89.         case "ecm":  
  90.             roundType = "ECM";  
  91.             skip = false;
  92.             break;  
  93.              
  94.         case "m":  
  95.             roundType = "Mines";  
  96.             skip = false;
  97.             break;  
  98.            
  99.         default:
  100.             skip = true;    
  101.             break;  
  102.     }    
  103.  
  104.     if (skip == false)
  105.     {
  106.         switch(input_split[1])  //round number  
  107.         {    
  108.             case "1":                
  109.                 panelToWrite = roundOnePanelName;    
  110.                 roundNumber = "One";
  111.              
  112.                 if (input_split[0] == "k" | input_split[0] == "he" | input_split[0] == "ecm" | input_split[0] == "m")
  113.                 {
  114.                     roundType_1 = roundType;
  115.                 }else{
  116.                     roundStatus_1 = roundStatus;
  117.                 }
  118.              
  119.                 Message = "Torpedo " + roundNumber + "\n-----------------------\n  Type:\n  -" + roundType_1 + "\n  Status:\n  -" + roundStatus_1;  
  120.                 break;    
  121.                
  122.             case "2":    
  123.                 panelToWrite = roundTwoPanelName;    
  124.                 roundNumber = "Two";  
  125.              
  126.                 if (input_split[0] == "k" | input_split[0] == "he" | input_split[0] == "ecm" | input_split[0] == "m")
  127.                 {
  128.                     roundType_2 = roundType;
  129.                 }else{
  130.                     roundStatus_2 = roundStatus;
  131.                 }
  132.                
  133.                 Message = "Torpedo " + roundNumber + "\n-----------------------\n  Type:\n  -" + roundType_2 + "\n  Status:\n  -" + roundStatus_2;    
  134.                 break;
  135.                
  136.             default:  
  137.                 break;  
  138.         }
  139.  
  140.         GridTerminalSystem.SearchBlocksOfName(panelToWrite,textPanels);      
  141.         for(int i=0 ; i < textPanels.Count ; i++)      
  142.         {      
  143.             IMyTextPanel panel = (IMyTextPanel) textPanels[i];        
  144.             panel.WritePublicText(Message);        
  145.         }        
  146.     }else{
  147.         Echo ("Invalid or null input: '" + input +"'");
  148.     }
  149. }
Advertisement
Add Comment
Please, Sign In to add comment