Rename Block Script
This is a full guide that will explain all the features of my Block Renaming script.
Script
Current Version:
- Version: 1.5.1b
- Date: 2019-04-25
Main features:
- rename blocks based on a search filter
- replace strings in blocknames with other one
- remove strings in blocknames
- create new continuous numbers for the blocks
- autosort the whole grid
- add specific strings to the front or back of your blocknames
- rename grids based on a block search filter
- filter blocks by name, group or type
Basic Setup:
- set up a programmable block with the script (no timer required)
- run the script with one of the following parameters as an argument (parameters are always seperated with a comma “,”):
- Note: Game has to be in experimental mode and ingame scripts have to enabled in world options!
Basic renaming:
Blocks are renamed to NEWNAME if the blockname contains OLDNAME.
The parameter FILTER is optional and filters the used blocks! All blocks that match the search are renamed if it’s missing:
- rename,OLDNAME,NEWNAME[,FILTER]
Replace:
Replace a string with another one.
The parameter FILTER is optional and filters the used blocks! All blocks that match the search are renamed if it’s missing:
- replace,OLDSTRING,NEWSTRING[,FILTER]
Remove:
Remove a string from your blocknames.
The parameter FILTER is optional and filters the used blocks! All blocks that match the search are renamed if it’s missing:
- remove,STRING[,FILTER]
Remove Numbers:
Remove numbers from your blocknames.
The parameter FILTER is optional and filters the used blocks! All blocknumbers are removed if it’s missing:
- removenumbers[,FILTER]
Sort
Create new continuous numbers for a list of blocks defined by FILTER (e.g. Refinery):
- sort,FILTER
Same as above but gives gives continuous numbers based one the grid:
- sortgrid,FILTER
Autosorting every block on your grid:
When given this parameter, the script will automatically sort every block on its 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 gridname as the second parameter. Partial gridnames are also detected, e.g.: “Small” will find “Small Grid 1283”, “Small welding ship” and “Escape Pod (Small)”
- autosort,GRIDNAME
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
Adding a string at the front or back of your blocknames:
This will add a specific string to your blocknames.
The parameter FILTER is optional and filters the used blocks! All blocks are renamed if it’s missing:
- addfront,STRING[,FILTER]
- addback,STRING[,FILTER]
Adding a string at the front or back of your blocknames on a grid:
This will add a specific string to all blocknames on a grid. The parameter GRIDNAME is needed to identify the grid you want add strings. Partial detection is enabled here, so “Grid” will find “Small Grid 1234” as well as “Large Grid 5678”.
The parameter FILTER is optional and filters the used blocks! All blocks are renamed if it’s missing:
- addfrontgrid,STRING,GRIDNAME[,FILTER]
- addbackgrid,STRING,GRIDNAME[,FILTER]
Rename a 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]
Undo the last operation
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”
Blockgroup: Use the group token “G:” and the groupname, e.g.: “G:Solar Rotors”
Blocktype: Use the type token “T:” and type and/or subtype name, e.g.: “T:Refinery/LargeRefinery”
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
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”.
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 script (steps above)
- 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