Space Engineers

Space Engineers

Renamer
4 Comments
CamariX 17 Jun, 2023 @ 10:03am 
[ i ] won't appear on my previous comment. all code without the problem

void Main(string argument)
{
String ShipName = "BASE - ";
String Rename = "LVLX - ";
String BlockName = "";
List<IMyTerminalBlock> Blocks = new List<IMyTerminalBlock>();
GridTerminalSystem.GetBlocks(Blocks);
for (int no = 0; no < Blocks.Count; x++)
{
BlockName = Blocks[no].CustomName;
if (Rename != "")
{
Blocks[no].CustomName = Blocks[no].CustomName.Replace(Rename, ShipName);
}
if (Blocks[no].CustomName.StartsWith(ShipName) == false)
{
Blocks[no].CustomName = ShipName + BlockName;
}
}
}
CamariX 19 May, 2023 @ 10:37am 
Back. This script has a small problem with renaming.
Just change line by :

if ( Blocks .CustomName.StartsWith(ShipName) == false)

Else the Shipname will be added to the actual name without renaming
CamariX 17 May, 2023 @ 2:25pm 
Works fine ! Use it with programming block
Pote 11 May, 2022 @ 7:22am 
Works well