Space Engineers

Space Engineers

53 ratings
Isy's Block Renaming Script Guide
By Isy and 1 collaborators
This is a full guide that will explain all the features of my Block Renaming script.

You can find the script here: https://steamhost.cn/steamcommunity_com/sharedfiles/filedetails/?id=913293538
   
Award
Favorite
Favorited
Unfavorite
Basic Setup
The basic setup is very easy. You just need a programmable block with the script and that's it! Below you have a step by step description of what to do:
  • subscribe to my script in the workshop (see link in the title)
  • build a programmable block
  • open it in the terminal
  • press 'Edit'
  • in the new window, press 'Browse Workshop'
  • select my script 'Isy's Block Renaming Script' and press 'Ok'
  • the code now appears in the window
  • press 'Check Code' and 'Ok' in the popup window
  • press 'Remember & Exit' and you're done

The script is now ready to run one of the commands found in this guide.

Note: Game has to be in experimental mode and ingame scripts have to enabled in world options!
How to do that, I explained here:

How to use the script?
The basic idea of the script, is to make your life easier when it comes to renaming your terminal blocks. The script can rename blocks, replace certain strings in blocknames or give them nice and tidy numbers.

To get started, you need to write the command, you want to use, in the argument field of the programmable block and press run to execute it. Different paramaters of the commands are always separated with a comma ',' . If you see parameters in brackets, like [,FILTER] it means, that this parameter is optional and not needed for the command to work.

In this example, we want to replace all blocknames containing "Spotlight" to just "Light".


In this case, there were only two blocks, that matched the criteria, but you can bulk rename up to several thousand blocks at once. The result of our command is this:


As you see on the right, the script will output, which blocks it found and how it renamed these.

Another example would be numbers. Space Engineers will give a new number to every block you build but this number will always be one higher than the number of the last block, you built of that type. Grinding down and rebuilding blocks will end up with numbers, that don't make much sense, but we can use the sort command for this:


As you see, our two Lights have ridiculously high numbers. Let's see what the script does with that:


The script was once again a time-saver. Just imagine doing this with 300 blocks by hand... Hilarious!

The next chapters will show and explain every command, you can use.
Rename
Blocks are renamed to NEWNAME if the blockname contains OLDNAME. The number of the block is preserved but every other part of the old name (even if not specified in OLDNAME) will be replaced by NEWNAME.

rename,OLDNAME,NEWNAME[,FILTER][,GRID]

  • FILTER is optional and filters the possible blocks! All connected blocks that match OLDNAME are renamed if it's missing!
    Learn more about filters in the guide topic Filters

  • GRID is optional and filters the grid, blocks can be found! Partial gridnames are enabled, e.g.: 'Isy' will find 'Isy's welder ship'. All connected grids are searched if it's missing!

  • Hint: To skip parameters, use asterisk *
Replace
Replace a string with another one.

replace,OLDSTRING,NEWSTRING[,FILTER][,GRID]

  • FILTER is optional and filters the possible blocks! All connected blocks that match OLDSTRING are renamed if it's missing!
    Learn more about filters in the guide topic Filters

  • GRID is optional and filters the grid, blocks can be found! Partial gridnames are enabled, e.g.: 'Isy' will find 'Isy's welder ship'. All connected grids are searched if it's missing!

  • Hint: To skip parameters, use asterisk *
Remove
Remove a string from your blocknames.

remove,STRING[,FILTER][,GRID]

  • FILTER is optional and filters the possible blocks! All connected blocks that match STRING are renamed if it's missing!
    Learn more about filters in the guide topic Filters

  • GRID is optional and filters the grid, blocks can be found! Partial gridnames are enabled, e.g.: 'Isy' will find 'Isy's welder ship'. All connected grids are searched if it's missing!

  • Hint: To skip parameters, use asterisk *
Remove Numbers
Remove numbers from your blocknames.

removenumbers[,FILTER][,GRID]

  • FILTER is optional and filters the possible blocks! All connected blocks are renamed if it's missing!
    Learn more about filters in the guide topic Filters

  • GRID is optional and filters the grid, blocks can be found! Partial gridnames are enabled, e.g.: 'Isy' will find 'Isy's welder ship'. All connected grids are searched if it's missing!

  • Hint: To skip parameters, use asterisk *
Default name
Sets blocknames to the default, localized name. For numbers, use autosort afterwards:

defaultname[,FILTER][,GRID]

  • FILTER is optional and filters the possible blocks! All connected blocks are renamed if it's missing!
    Learn more about filters in the guide topic Filters

  • GRID is optional and filters the grid, blocks can be found! Partial gridnames are enabled, e.g.: 'Isy' will find 'Isy's welder ship'. All connected grids are searched if it's missing!

  • Hint: To skip parameters, use asterisk *
Sort
Create new continuous numbers for a list of blocks defined by FILTER:

sort,FILTER[,GRID]

  • FILTER is mandatory and filters the possible blocks!
    Learn more about filters in the guide topic Filters

  • GRID is optional and filters the grid, blocks can be found! Partial gridnames are enabled, e.g.: 'Isy' will find 'Isy's welder ship'. All connected grids are searched if it's missing!
Sort by grid
Same as above but gives gives continuous numbers based one the grid. So if several blocks with the same name on different grids are found, 'sortbygrid' will give new numbers for each grid separately instead of continuous numbers for all (see pictures):

sortbygrid,FILTER

  • FILTER is mandatory and filters the possible blocks!
    Learn more about filters in the guide topic Filters

Sort will give continuous numbers across the grids.

Sortbygrid will give each grid its own continuous numbers.
Autosort
When given this parameter, the script will automatically sort every block on its own grid with continuous numbers while adding the correct amount of leading zeros based on the total number of blocks for each type of block. All the names stay intact.

autosort

To autosort a specific grid, use the GRID as the second parameter. Partial gridnames are also detected, e.g.: "Isy" will find "Isy's welder ship".

autosort,GRID

In order to autosort every block on every connected grid, you can use the following parameter (based on the size of your station, this could crash the script!):

autosort,all
Add string
This will add a specific string to your blocknames. Strings can either be added to the front or the back by using the respective command. The script won't add the string again if it's already there, so executing the same command again will only add your string to blocks, that don't already have it.

addfront,STRING[,FILTER][,GRID] addback,STRING[,FILTER][,GRID]

  • FILTER is optional and filters the possible blocks! All connected blocks are renamed if it's missing!
    Learn more about filters in the guide topic Filters

  • GRID is optional and filters the grid, blocks can be found! Partial gridnames are enabled, e.g.: 'Isy' will find 'Isy's welder ship'. All connected grids are searched if it's missing!

  • Hint: To skip parameters, use asterisk *
Rename a grid
This renames a grid. Although you can do this in the info tab, you sometimes have subgrids with no access. The script can do it for you by identifying the grid via a block that is on the grid.
The parameter BLOCKONGRID is optional and is only needed to identify a subgrid. The grid of the PB is renamed if it's missing:

renamegrid,NEWNAME[,BLOCKONGRID]
Copy custom data
You can copy the custom data from one block to all blocks matching FILTER. This is especially useful for 'Special' containers of my Inventory Manager. The syntax is:

copydata,BLOCKNAME,FILTER[,GRID]

To avoid confusion, BLOCKNAME is the source and should match as exactly as possible with the full blockname of the block you want to copy from, otherwise it might first find a similarly named block and copy from that one instead.

  • FILTER is mandatory and filters the possible blocks you want to copy to!
    Learn more about filters in the guide topic Filters

  • GRID is optional and filters the grid, blocks can be found! Partial gridnames are enabled, e.g.: 'Isy' will find 'Isy's welder ship'. All connected grids are searched if it's missing!
Delete custom data
You can delete the custom data of all blocks matching FILTER. The syntax is:

deletedata,FILTER[,GRID]

  • FILTER is mandatory and filters the possible blocks you want to delete the custom data!
    Learn more about filters in the guide topic Filters

  • GRID is optional and filters the grid, blocks can be found! Partial gridnames are enabled, e.g.: 'Isy' will find 'Isy's welder ship'. All connected grids are searched if it's missing!
Undo
Mistakes are made, but no worries ;)
If you made a mistake and want to undo your last operation, run the program with the following argument:

undo
Filters
Everwhere you see a FILTER in the syntax you can either use a blockname, a blockgroup or a blocktype as a filter.

Blocknames
Simply use the blockname, like "Assembler" or a partial blockname, like "Turret", which will find "Gatling Turret", "Missile Turret" and "Interior Turret".

Blockgroup
This will find any user made block groups by name. Use the group token "G:" and the groupname, e.g.: "G:Solar Rotors".

Blocktype
This will find any block type or partial block type. Use the type token "T:" and type and/or subtype name, e.g.: "T:Refinery/LargeRefinery" will find any large refineries or "T:Assembler" to find "Assembler/LargeAssembler" and "Assembler/BasicAssembler"
Modifiers
By adding modifiers as an additional parameter to your command, you can change the way, they are executed. Modifiers can added to every command as the last parameter!

Sort mode:
Sortmode can be applied to every operation. It sorts the current selection after renaming.
Add this parameter at the end of your argument, e.g.: 'replace,OLDSTRING,NEWSTRING,!sort':

!sort

Testmode:
If you want to see your planned names without actually renaming any block, you can use testmode. Just append this as another parameter to your argument line, e.g.: 'replace,OLDSTRING,NEWSTRING,!test':

!test

Help:
Every command accepts '!help' as an additional parameter. Just append this as another parameter to your argument line to see the help for this command, e.g.: 'autosort,!help':

!help
LCD output
The following topic explains, how to use LCD panels (regular and block LCDs) of my script. Whenever you add one of the following keywords to a LCD name, the keyword gets transformed to the universal [IsyLCD] keyword. In the custom data, you can then set different options about the LCD as well as the screen, the information should be shown (on blocks like cockpits, programmable blocks and so on). The custom data will look like this:

@# !KEYWORD

@# stands for the screen, the information is shown, where # is the screen identifier number from 0 to the max number of screens - 1. A programmable block for example has two screens: The main screen and the keyboard. Both can be used to show the script informations (screen 0 and screen 1). To change the screen, you want to show your informations, just edit the screen identifier number in the custom data.

It is also possible to display informations of different scripts in one block by using this syntax (MMaster's Automatic LCDs 2 uses the same syntax and all of my other scripts).

LCD Keywords
Main LCD
You can display all the main script informations that are also shown in the console on the main LCD. Just add the following keyword to a LCD name:
[IBR-main]
Some examples
rename,Interior Light,Base Light,!sort
This will rename all blocks that contain "Interior Light" to "Base Light" and create new continuous numbers with automatic leading zeros, e.g.: "Base Light 01", "Base Light 02", ..., "Base Light 10"

replace,Sliding Door,Door
This will replace the word "Sliding Door" with "Door" on all blocks that contain it. All other parts of the name stay intact, e.g.: "Basement Sliding Door Right 1" will be renamed to "Basement Door Right 1"

autosort,!test
This will attempt to autosort every block on your grid, but only shows you the new names without actually doing anything because testmode was given as a parameter.

addfront,[Isy],Reactor
This will add "[Isy]" in front of every blockname on every connected grid, that contains "Reactor".
52 Comments
Isy  [author] 31 Jan @ 5:40am 
No, that's not possible.. Scripts can't do that kind of terminal interaction
andrew.mcallister 8 Jan @ 1:43pm 
Once one has renamed a group, is it feasible for a script to pick up any actions that lock had that referred to that group, basically looking for actions that have been broken by the manual renaming? eg renaming a group of welders and then the sensor not turning them off anymore as the old name no longer exists.
Isy  [author] 5 Dec, 2024 @ 10:00am 
Nope, not possible via script.. Select the group, change the name and hit save, delete the old one..
Shooter 4 Dec, 2024 @ 11:41am 
Any way to change group name?
Isy  [author] 17 Nov, 2024 @ 11:04am 
Nice ;)
Uncertain Atomic 16 Nov, 2024 @ 7:04pm 
Creating my list of renaming arguments in an EA2 CodeBlock. The Easy Automation2 running on one programming block runs a second programming block with your renaming script over and over with each argument loaded. It does all of my persnickety renaming for every block on the grid instantaneously. I saved the arguments in a text file to copy paste into a CodeBlock of any new ship I build. After its run once I can just delete the Custom data of the EA2 CodeBlock. Scripts are amazing.
Uncertain Atomic 16 Nov, 2024 @ 5:59am 
Thank you for the idea on timer blocks. There are enough arguments that I use, that yeah, a renaming ship/station might be in order. The workaround I found, and I'm going to try first is using Coren's Easy Automation to run your program multiple times with the different arguments. That way whenever I build a new ship I can cut and paste some custom data, run two programing blocks, then everything will be renamed. I'll post an update if/when I get it one of these ideas working. Thank you again for all of your hard work on creating this script.
Isy  [author] 9 Nov, 2024 @ 11:55pm 
No, but you could use a series of timer blocks that execute the commands and save it as a blueprint.. Maybe even a renaming ship that comes along, docks and brings everything in order ;)

My recommendation would be to use timers with a slight delay, so:
Timer 1: executes script with argument, starts Timer 2
Timer 2: executes script with another argument, starts Timer 3
and so on..
Uncertain Atomic 2 Nov, 2024 @ 12:27pm 
Isy thank you for this script. Block renaming is a tedious part of the game and this makes it A LOT easier. Question: I dislike the default naming system and have a specific way that I like to rename all blocks. Using your script I have generated a list of arguments that I use on newly created grids. Is it possible to execute multiple arguments at the same time. Possibly through adding a section to your script. I currently cut paste from another document. Thank you again for this amazing creation.
kinngrimm 21 Feb, 2024 @ 8:39am 
ok, thx for clarifying