Advertisement
Sherbert

Privacy Shade Script

Jul 8th, 2020
1,042
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.24 KB | None | 0 0
  1.  
  2.         /// <summary>
  3.         /// Sherberts Privacy Shades Script (Idea by YouFoundMe)
  4.         /// When ran will toggle clear lcd's with the set tag to have an image or become clear.
  5.         /// Setup, Place Programing block, and LCD's - change LCD names to include tag.
  6.         /// If seperate images are wanted for each LCD put the image text generated from Whip's Image convertor
  7.         /// into the custom data of desired lcd's
  8.         /// If the same image is desired leave all lcd's custom data empty and put the image text from Whips converter into the
  9.         /// Programing block's custom data
  10.         /// run programing block,either by hand or threw a button and it will toggle between clear and the images
  11.         /// Enjoy
  12.         ///  
  13.         ///
  14.         /// </summary>
  15.  
  16.         string tag = "[Shade]";
  17.  
  18.         List<IMyTerminalBlock> lcd = new List<IMyTerminalBlock>();                            
  19.  
  20.  
  21.         public void Main(string argument, UpdateType updateSource)
  22.         {
  23.            
  24.             GridTerminalSystem.SearchBlocksOfName(tag, lcd);
  25.             string defaultimage = Me.CustomData;
  26.  
  27.             if (lcd.Count!= 0)
  28.             {
  29.                 foreach(var i in lcd)
  30.                 {
  31.                     IMyTextSurfaceProvider panel = i as IMyTextSurfaceProvider;
  32.                     if(panel != null)
  33.                     {
  34.                         IMyTextSurface screen = panel.GetSurface(0);
  35.                         screen.ContentType = VRage.Game.GUI.TextPanel.ContentType.TEXT_AND_IMAGE;
  36.                         screen.FontSize = 0.1f;
  37.                         screen.Font = "Monospace";
  38.                         string text = screen.GetText();
  39.                         if(text != "")
  40.                         {
  41.                             i.CustomData = text;
  42.                             screen.WriteText("");
  43.                         }
  44.                         else
  45.                         {
  46.                             if (i.CustomData != "")
  47.                                 screen.WriteText(i.CustomData);
  48.                             else
  49.                                 screen.WriteText(defaultimage);
  50.                         }
  51.  
  52.                     }
  53.                 }
  54.  
  55.  
  56.             }
  57.  
  58.         }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement