Space Engineers

Space Engineers

CAT Add Prefix to All Blocks
13 Comments
Loues.S.Cat  [author] 18 Feb, 2016 @ 2:18pm 
Ohh it is the old old version....
You're better off using the group based renaming one linked in the description.
Loues.S.Cat  [author] 18 Feb, 2016 @ 2:17pm 
This script threw an error?
How odd. I was using it myself quite recently. I will have a look.
And to the best of my knowledge you can't grab the name of a ship.
It was made before you could run scripts with arguments, or use Echo but that is a good idea for an upgrade.
SciDerg 18 Feb, 2016 @ 1:14pm 
Grabbing the name of the ship and using that might get clumsy, my ships often have long-ish names ("Large Cargo Freighter"), but I prefix all the blocks with a much shorter version or acronym so I can actually see which block I'm clicking on.
Just getting the ship name in this case would give me a page full of"Large Cargo Freighter ..." entries, and I wouldn't see the full name until I clicked on the block.

I'd say you could just make it use a string from the argument box, and that would work fine.
If you wanted the full ship name, you'd only have to type it in once, and you wouldn't need to open up the script editor, just change the text in the argument box.
SciDerg 18 Feb, 2016 @ 1:07pm 
Script didn't compile for me when I tried it, but a small tweak to the line 9 (inside the "AddPrefixToAll()" function)restored it to working order.
I then made a few more tweaks to generally update and clean up the code, but I didn't touch the core logic of it.

I replaced line 9 with this:
List<IMyTerminalBlock> blocks = new List<IMyTerminalBlock>();
GridTerminalSystem.GetBlocksOfType<IMyTerminalBlock>(blocks);

After that, I changed the list index variable to " i " instead of " j " because " i " for index makes more sense to me.

Finally, I replaced the call to "Print()" with "Echo()", and deleted the code defining "Print()".
The Echo function actually works better here because it prints out text directly to the programmable block's menu, and because it's a default function you don't need to define it, saving program space.

Oh yeah, I also re-whitespaced the whole thing, as I prefer al my curly brakets to be on their own lines.
jarhead 5 Apr, 2015 @ 4:18am 
me too thats why i asked. lol
Loues.S.Cat  [author] 5 Apr, 2015 @ 4:12am 
If you can tell me how to get the name of the ship, sure. As I am not aware of any means to do so I would love to know how to grab a ships name.
jarhead 5 Apr, 2015 @ 3:40am 
Could you adjust this script to look for the name of the ship and add that as a prefix to all of the blocks on that ship.
Loues.S.Cat  [author] 5 Apr, 2015 @ 3:36am 
Yes, I rather like prefix filtering.
This script is a bit outdated. I use a group based renaming script now.
By using a group based renaming system you can run the same script on any programable block and set a group to decide what to rename target blocks connected to that grid so no editing of the script is needed.
jarhead 5 Apr, 2015 @ 3:33am 
This is perfect for use with a gps guided mining ship. Now If only I could get the scripts that are used in them changed so they just look for the ship name and put the in the spot they need to so they can look for that as a prefix for the blocks (I am trying to get it so I can have as many of the same ship as possible docked to the same station at the same time without having the scripts from one messing with the others.
Loues.S.Cat  [author] 12 Feb, 2015 @ 11:44am 
Can you describe the behavior you are after?
Judgernaut 12 Feb, 2015 @ 11:19am 
That would be sublime, Ive ran into this problem so many times now :)
Loues.S.Cat  [author] 12 Feb, 2015 @ 11:15am 
Hmm... No. I will look into that now.
Judgernaut 12 Feb, 2015 @ 10:58am 
Does it also give the prefix to group names?