Space Engineers

Space Engineers

CAT Group Based Renaming
41 Comments
Flatfoot 16 May, 2020 @ 1:52pm 
For some reason, whenever I use adaptive LoN (Gl_LoN=0), the script likes to add way to many zeros for numbers past 20. (Gives 3+ for 30).

I tweaked a fix by the following code.
[code]
public int getLoN( int cnt ) {
int lon = 0;
if( GI_LoN <= 0 ) { lon = cnt.ToString().Length;
//lon = 2;
//while( cnt / (1f+(10f*lon)) >= 1 ) {
// lon++;
//}
} else {
lon = GI_LoN;
}
return lon;
} [/code]
Thundagar 26 Oct, 2019 @ 6:08pm 
Thank you verry much :)
Dragon18Actual 19 Oct, 2019 @ 4:37pm 
Once you get the script set up in a programable block, create a group from the control panel of all the things you want the name modifed. So for example, if you got 100 O2 generators, and want to rename them and number them, you'd select them all, then name the group "$RENAME# My Oxygen Generators (Or what ever you want them to be called)" then save the group, then go to the programable block and hit "Run"

Should be close to that anyway, it's been awhile since I've played, but in short, it's all in how you name the group.
Thundagar 19 Oct, 2019 @ 2:36pm 
I'm a noob to these scripts and how to use them fully, i do know you add them to programable blocks and how to load them. have gotten a couple scripts running fine but how do you use this script. do you add the $ADDPREFIX <ShipName> to the argument line and then click run or is there another way your supossed to do this? thanks for any help :)
Dragon18Actual 28 Apr, 2019 @ 7:43pm 
Sorry to double post. Just thought I'd let everyone know. I've been playing this again a bit today and this still works.
Dragon18Actual 13 Jan, 2019 @ 7:43am 
I haven't played in a couple of months, but the last time I played, it still worked fine.
DarthNovii 12 Jan, 2019 @ 8:29pm 
Is this still working?
Nixx 10 Nov, 2017 @ 8:50am 
int issue on line 22
Loues.S.Cat  [author] 23 Oct, 2017 @ 7:21pm 
I could do. Though right now it is 3am so... later... because it can't get too much earlier than 3am X.x
Flatfoot 23 Oct, 2017 @ 6:46pm 
Loues, did you integrate the REMOVETAG and REPLACETAG functions into your script?
Dragon18Actual 23 Oct, 2017 @ 6:37pm 
Seems to be working perfectly. Thanks again.
Loues.S.Cat  [author] 23 Oct, 2017 @ 3:45am 
Let me know if you have any problems.
I did basic testing but that doesn't mean I didn't mess up somewhere.
Dragon18Actual 23 Oct, 2017 @ 3:44am 
Thank you so very very much.
Loues.S.Cat  [author] 23 Oct, 2017 @ 3:37am 
That should work now.
Also added $CLEAR while I was at it whould should do language safe restoration to default name.
Loues.S.Cat  [author] 23 Oct, 2017 @ 1:06am 
Umm... Yes.. yes there is... give me a bit.
Dragon18Actual 22 Oct, 2017 @ 11:24pm 
Is there a way to modify this so it will number the blocks with triple digits? I've never liked how the game sorts things so you end up with 2 down by 20 and 200 and so forth... I usually number things 001 and 010 etc. so they stay in numerical order. I'm very new to this and any help will be appreciated.
Flatfoot 3 May, 2017 @ 3:22pm 
Loues, great working script. Are there any updates being worked, to bring it up to the recent API changes?
Flatfoot 9 Jan, 2017 @ 3:08pm 
I've done that. Slight additions to the code; but it supports replacing or removing a tag
Loues.S.Cat  [author] 9 Jan, 2017 @ 9:09am 
Hmmm.
That could be worth adding.
I shall look into it when I have a moment.
Acarii 8 Jan, 2017 @ 8:17pm 
This script looks almost like what I need. I need a script that can find a given tag and remove and/or replace it.
Flatfoot 9 Oct, 2016 @ 11:17pm 
Last Part:

/* Used to place a tag on a block name with another tag */
public void ReplaceTagGroup( List<IMyTerminalBlock> blocks, string tag ) {
GROUPS += 1;
var tparsed = tag.Split( '|' );
var otag = tparsed[0];
var ntag = tparsed[1] ;
string name = null;
for( int e = 0; e < blocks.Count; e++ ) {
ACTIONS += 1;
name = blocks[e].CustomName;
if( name.Contains( otag ) ) {
name = name.Replace( " " , " " ).Replace( otag , ntag );
blocks[e].SetCustomName( name.Trim() );
}
}
}
Flatfoot 9 Oct, 2016 @ 11:16pm 
Part 2:

and add these lines in somewhere... ( I put them right before the Display Method ):

/* Used to remove a tag from a block name */
public void RemoveTagGroup( List<IMyTerminalBlock> blocks, string tag ) {
GROUPS += 1;
string name = null;
for( int e = 0; e < blocks.Count; e++ ) {
ACTIONS += 1;
name = blocks[e].CustomName;
if( name.Contains( tag ) ) {
name = name.Replace( " " , " " ).Replace( tag , "" );
blocks[e].SetCustomName( name.Trim() );
}
}
}

Flatfoot 9 Oct, 2016 @ 11:14pm 
Sorry about the wall of text

Cobbled together a removetag and replacetag method for this extremely helpful script..

replace:
AddPrefixGroup( blocks, name, true );
}
}
}
}

with:
AddPrefixGroup( blocks, name, true );
} else if( act.Equals( "$REMOVETAG" ) ) {
List<IMyTerminalBlock> blocks = new List<IMyTerminalBlock>();
groups[e].GetBlocks( blocks );
RemoveTagGroup( blocks, name );
} else if( act.Equals( "$REPLACETAG" ) ) {
List<IMyTerminalBlock> blocks = new List<IMyTerminalBlock>();
groups[e].GetBlocks( blocks );
ReplaceTagGroup( blocks, name );
}
}
}
}
Flatfoot 9 Oct, 2016 @ 9:12pm 
Ok, verified working.. just a weird glitch stopped it from working that particular instance.

@Xeo: Could you post those methods for removing and replacing tags, or show me where it's stored?
Flatfoot 26 Sep, 2016 @ 7:29am 
As of Sep 26, this doesn't appear to be working. Dedicated Server. Actions performed: recompiled (success), reloaded script, checked case typing, checked ownership. No Joy.

Works on my own local save, but not on the dedicated server that I play on.
Xeo 12 Apr, 2016 @ 8:33am 
First, thanks for this awesome script ! Saved me the trouble of figuring out how to do this on my own (no way I'd do that manually & I really needed to add prefixes on a bunch of ships to make Mmaster LCD script work nicely).

Secondly, I added both a $REPLACETAG and a $REMOVETAG methods for my personal use. As I can see such functions have been requested in previous comments, I'd happily give you access to my modified version of the script if you want to save yourself the small hassle of coding them yourself.

Keep up the good work !
Loues.S.Cat  [author] 2 Mar, 2016 @ 8:05am 
Happy to help, and I think that could be added.
As I use this script a lot myself It would be useful to me as well.
Just give me a bit.
Sutima 2 Mar, 2016 @ 7:55am 
So Mr. Cat, Is there a possibility of adding a $RemoveTAg/prefix aswell or something along those lines =) ..
I just LOVE this btw, use it on a daily basis, So thanks for sparing my countless of crashes due to Copypaste text crashing my game =)
Rusted Droid 1 Mar, 2016 @ 4:05am 
Loues.S.Cat, I see.... Well i hopped that there is a way of auto renaming the ship. At least static defined Name in script that on trigger will rename the ship...It is quite annoying always do this by hand... Best will be if merge block has status info (Connected/unconnected) but it doesn't have that... and i don't think that there is a way to read this info even by script. :/ One way to determinate if ship was unmerged can be.. Each of Ship will remember with +/- tolerance what blocks(grid) and shape it has before merge. When they merge, it will count the additional blocks (or one specified) found. After unmerge script will check how many blocks was lost (or those specified).
Loues.S.Cat  [author] 1 Mar, 2016 @ 2:15am 
Well, the are a few problems witht hat. In game scripts don't have access to the ships grid object in a way that they can rename it. On top of that, can you sugest how the script should determin when two ships unmerge?
I can make a script that gets the entire local grid so it can identify blocks that are on the same grid as the programable block, ignoring anything on the other side of connectors, pistors or rotors, buit merge blocks make a two grids into one grid, but when it comes to merge blocks the only way I can see for it to know the grids are split is to check the size of the grid and run renaming on individual blocks based on that. But that could be triggered by other ships unmerging, damage, or deconstruction.
Rusted Droid 1 Mar, 2016 @ 1:16am 
Can you make script that when two ships un-merge (disable MergeBlocks) it will use part of name from programing block and rename the generated Ship Large Grid **** to the part of Programing blok name? Example:(Programing block name PB_Destroyer-22B8 to info pannel rename Ship Ship Large Grid **** to Destroyer-22B8)
Loues.S.Cat  [author] 12 Sep, 2015 @ 8:12am 
Indeed. I thought of adding something like that myself. I would want it to be seperate since I do these scripts for myself and I don't like the sequential numbering system :p
Flatfoot 12 Sep, 2015 @ 4:30am 
Very nice script, might I suggest changing the line (line 43/82 in the .27Jul15 version) in the $RENAME function;

FROM: blocks[e].SetCustomName( name );
TO: blocks[e].SetCustomName( name + " " + (e+1));

in order to add sequential numbers? Could also be a 4th "$RENAME#" subfunction, to preserve the identical name capability this provides.
Flatfoot 29 Jul, 2015 @ 10:26am 
Thank you, kindly!
Loues.S.Cat  [author] 27 Jul, 2015 @ 7:10pm 
There you go!
Should be working again now.
Made a few changes, took advantage of echo and updated for the GridTerminalSystem changes
Let me know if you still have issue.
Loues.S.Cat  [author] 27 Jul, 2015 @ 6:44pm 
Ohh sure. let me look it over and I'll upload a new version asap
Flatfoot 27 Jul, 2015 @ 6:43pm 
With the recent API 'adjustments' made by Keen, this script, as were many others, no longer works. Is there an update in the works?

It's a nice script.
Loues.S.Cat  [author] 30 Mar, 2015 @ 11:22am 
Nope
Mictlan 30 Mar, 2015 @ 10:00am 
Is their a way to produce a script that auto hacks a ships owner and sets it to someone else or even to neutural?

like say i have one ship... i build a merge block on it and a programmer block... than i have another ship... (not owned by me) and i add a merge block on to it... and the programming block converts the ship owner to me?
Loues.S.Cat  [author] 14 Feb, 2015 @ 6:04pm 
Let me know if you can't find anything I might be able to put together for you.
I'm happy to produce new scripts.
Sflot 14 Feb, 2015 @ 6:03pm 
I'm trying to find every script that could help me organize my ships' menus. This will surely help a lot, thanks!