Advertisement
Guest User

Light example

a guest
Jul 23rd, 2019
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.97 KB | None | 0 0
  1. //x3,1,#test,22[5]2:255:0:0[7]%,y,,1.1.1
  2. // Above is your LOAD LINE. Copy it into Visual Script Builder to load your script.
  3. // dco.pe/vsb
  4.  
  5. void Main(string argument)
  6. {
  7.   // block declarations
  8.   string ERR_TXT = "";
  9.   List<IMyTerminalBlock> v0 = new List<IMyTerminalBlock>();
  10.   if(GridTerminalSystem.GetBlockGroupWithName("test") != null) {
  11.     GridTerminalSystem.GetBlockGroupWithName("test").GetBlocksOfType<IMyInteriorLight>(v0, filterThis);
  12.     if(v0.Count == 0) {
  13.       ERR_TXT += "group test has no Interior Light blocks\n";
  14.     }
  15.   }
  16.   else {
  17.     ERR_TXT += "group test not found\n";
  18.   }
  19.  
  20.   // display errors
  21.   if(ERR_TXT != "") {
  22.     Echo("Script Errors:\n"+ERR_TXT+"(make sure block ownership is set correctly)");
  23.     return;
  24.   }
  25.   else {Echo("");}
  26.  
  27.   // logic
  28.   foreach(IMyInteriorLight interiorLight in v0) {
  29.     interiorLight.Color = new Color(255, 0, 0);
  30.   }
  31. }
  32.  
  33. bool filterThis(IMyTerminalBlock block) {
  34.   return block.CubeGrid == Me.CubeGrid;
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement