[SCRIPT] Rename Ships with Expressions (v1.4 Feb 1 07)

The place to discuss scripting and game modifications for X³: Reunion.

Moderators: Moderators for English X Forum, Scripting / Modding Moderators

djkaos
Posts: 74
Joined: Fri, 5. Mar 04, 00:19
x2

Post by djkaos » Thu, 21. Dec 06, 03:27

I never noticed this script before. :o Very nice. :thumb_up:

ShadowWolf_Kell
Posts: 35
Joined: Sun, 3. Sep 06, 07:27
x3tc

Post by ShadowWolf_Kell » Thu, 21. Dec 06, 16:42

This is exactly what I've been looking for!

Vanel
Posts: 71
Joined: Mon, 26. Dec 05, 13:06
x4

Post by Vanel » Thu, 21. Dec 06, 17:45

Excellent script. Makes ship management WAY easier 8)

User avatar
Sesk
Posts: 441
Joined: Fri, 17. Nov 06, 21:09
x4

Post by Sesk » Thu, 21. Dec 06, 19:33

Sounds interesting, i was looking for something like that for ages !

User avatar
Klyith
Posts: 594
Joined: Fri, 6. Jan 06, 01:38
x3

Post by Klyith » Sun, 7. Jan 07, 22:52

New version in a day or two. Formation / followers renaming, two colors that I missed the first time (cyan & magenta), and...

<x3partytime.png> <x3seriousbusiness.png>

Krazy Kolors!
Last edited by Klyith on Fri, 2. Feb 07, 14:41, edited 1 time in total.

User avatar
Klyith
Posts: 594
Joined: Fri, 6. Jan 06, 01:38
x3

Post by Klyith » Tue, 9. Jan 07, 22:21

Updated to version 1.3

The second RSwE command now does formation renaming, in addition to the old functions of homebased / docked ship renaming. It now works like this: you select a ship/station, enter the RSwE string, and then answer an incoming message with options for Formation, Followers, Homebase, or Docked. Only options relevant to the selected ship or station are shown, so normal ships get formations & followers, stations get homebase & docked, and carriers get all four.


I think I'm pretty much done with this one, unless I get any new requests.
8) \m/ :D et cetera

Brand-X
Posts: 232
Joined: Thu, 15. Sep 05, 23:48
x3

Post by Brand-X » Sat, 27. Jan 07, 02:15

Hello, Klyith,

This was a great idea.

I wonder if parts of it might be adapted to display station names and the other associated info displayed on the sector maps in colors that would change according to which of a couple conditions a station might be in.

I'll try to explain a little.

I am working on a script that allows players to capture stations. After a player captures a station and the ownership is set to him, the station is displayed at the top of the map, as I'm sure you know.

I used the info from an old thread by AalaarDB - make a text page with a couple color values on it, something like 33XYellow33X, 33XBlue33X, I can't recall just offhand. And I used the format text blah, blah, to set the DisplayName to yellow after a capture. That works great, even displays the name in color in logbook messages and on the property screen. Perfect, almost.

But, in my model, there are a couple ways to own a station that has been captured. One is that the player retains operation of the station, and it remains listed at the top of the map, in yellow.

The other way is that the player can return the station to operation by the original owners - retaining his warlord rights of taking back control whenever he wants, even temporarily - and in that case the station is displayed down with the rest of the stations, still in yellow. Which is cool. It provides a easy way to tell at a glance which stations you control.

However, there is the possibility of rebellion by the stations that you have returned to race operation, and when they do that they set you as an enemy, the background turns red, and they are moved up to the enemy section of the map, still displayed in yellow.

What I'd like to do is have the display name turn blue at that point, in order to differentiate it from other stations that might have you set as an enemy also, although the yellow does do that, too.

But after a time I want the station to 'normalize' relations with the player - assuming he doesn't reconquer it - to a level on par with ones relation to the race as a whole, and I need some means to tell it apart from other 'race operated' stations that you might own. Which would still be displayed in yellow.

However, when I tried to use the format method to change the color to blue - from yellow - it did not work and the names remained yellow.

I thought perhaps you might know why. Is it not possible to change the colors 'on the fly', so to speak? Could it be because after I initially change the color I store the stations in a couple arrays? Although after a station has rebelled, it is removed from any array.

Is there a better way to do what I want, without resorting to any mod stuff? just a better way to do it within my scripts?

Didn't mean to unload such a massive post on you. Your thread on the scripting forum caught my eye and I thought I'd ask.

:)

User avatar
Gazz
Posts: 13244
Joined: Fri, 13. Jan 06, 16:39
x4

Post by Gazz » Sat, 27. Jan 07, 03:49

An awesome script indeed.

I made several cosmetic changes for personal use but I wont release that. Basically it renames my whole empire to my specifications at one click. =)
A simple frontend to the frontend that goes through all the moves... nothing fancy.

Some things you may consider, though...

*ZN : change leading zero to a leading space. Its far more eye friendly and does not affect sorting.

I added a *TS expression. This returns only the first word of the verbose ship name except when that word is "Pirate" (on my captured Pirate Nova Raider =) in which case it returns the 2nd.
A ship name of "Pirate" seemed silly. Arr.

*FP : I only check $currentship -> get formation follower ships
If that doesnt return false, this ACTUAL leader of a wing is designated "Leader".
I feel that adding beta, gamma, etc. to every ship in the wing would only clutter up the display removing the advantage of being able to spot the wing leaders that you actually control.

*HB : using that expression for a TP / TS automatically translates into a generic "Factory" tag so I can easily tell my factory and fleet support ships from my UT.
The actual homebase is noted below the freighter anyway and the name is too long and effectively unreadable with adding the full homebase.

On the subject of fleet support TS... as I said before I did a simple frontend to the frontend.
After the first universe wide run on TS/TP it does a second one renaming all TS/TP in my current sector like "*ON *KCSupport"
My tankers and such are typically *with* my main fleet so that seemed like the only usable condition.
On a second thought, I am stupid. I shoulda queried the Fleet Support Ship Software in my tankers for that. =P
Owell. Live and learn!

PS: 2 colour codes were implemented but missing from the online help text. Not sure if thats corrected in your latest version.

PPS: The old Disco issue...
Discoverer is an M4 or M5, depending on who you ask. =P
Needs some haxxoring for the queries to work "right".

PPPS: Make sure to add *KX to the end of EVERY $namestring right at the start of .frontend
Not doing so results in corrupted colours in many messages from other scripts.
Not a crash bug but... the smooth thing to do. =P

PPPPS: Come to think of it, I will put the one-click-renaming into the main script, too.
In the Frontend, on a $where of 99, simply spawn the 2nd frontend which does all the defaults and recursively calls the .frontend script to do the actual work.
I like a slim interface and there's no point in using any more command slots.
That might actually be a selling point. A lot of users (like me =) do NOT want to enter long cryptic expressions over and over again. Just press ze button and live with intelligent defaults...
I guarantee you that many uninstall this thing the 2nd time they have to enter *KY*CL *TS *KW*ZN *KY*FP blah blah...
That's assuming they even piece it all together to GET to that string.

Nothing personal but in it's current form the script is for people who talk binary.


Edit:
Added *TP : Returns a factory's main product,
Disco mess (crudely) fixed - since I lump all M4 and M5 together in the Small Stuffs category.
Added *NV : Naming convention specially for satellites. Does not rename non-standard satellites (like Trade Beacon) which would break some scripts that use those. Any tags after Blahblah Satellite are always retained as well.
Will be adding "Gate" tags to the sats I deploy to keep an eye on gates, too. Yes, I use hundreds of sats all over the universe.
My complete script download page. . . . . . I AM THE LAW!
There is no sense crying over every mistake. You just keep on trying till you run out of cake.

User avatar
Gazz
Posts: 13244
Joined: Fri, 13. Jan 06, 16:39
x4

Post by Gazz » Sat, 27. Jan 07, 16:27

Added
*TH : returns a plain "Factory" if a homebase is set - for my factory TS.
*TU : returns "Support" if Fleet Support Software is installed.

Since I use all-at-once renaming with one button and this can take a while I moved the (combined) script to a dummy actor so it doesnt lock up the playership any more.

Well, I think that's it. It now does everything *I* want. =P

If you wanna incorporate all or some of those changes, fine. You can have the script and I dont really care much for credits. Works for me so I'm happy.

This is the result of clicking ze Button:[ external image ]
My complete script download page. . . . . . I AM THE LAW!
There is no sense crying over every mistake. You just keep on trying till you run out of cake.

Whooosh
Posts: 7
Joined: Sun, 14. Jan 07, 14:53
x3tc

Post by Whooosh » Sun, 28. Jan 07, 15:43

Would it be possible to script in Roman Numerals?

I just like using them. I'm old fashion.

User avatar
Gazz
Posts: 13244
Joined: Fri, 13. Jan 06, 16:39
x4

Post by Gazz » Sun, 28. Jan 07, 17:59

I'm sure it is.
All you need to do is write a library to translate decimal to roman, quintdecimal, binary, or whatever else you fancy.
Then simply put that call in the script to translate every number before printing it somewhere.
AFAIK there are only 2 spots where this script does numeric output so that's not too bad.
My complete script download page. . . . . . I AM THE LAW!
There is no sense crying over every mistake. You just keep on trying till you run out of cake.

Greg_G
Posts: 110
Joined: Tue, 26. Apr 05, 19:15
xr

Post by Greg_G » Mon, 29. Jan 07, 03:30

I have a feature request:

I would be very useful to me if the script were to first expand the clipboard expressions (*Y#) before all the other expressions. This way one can save expressions into the clipboard. This is because I tend to need to rename a lot of my ships one at a time (not in formations or groups, not all of the same class, and all in different sectors) and typing *KMStorage*KX (*CL|*TA|*SC) for each ship is rather tedious.

Obviously it would be important to make sure the user never caused a loop (e.g. putting *Y1 inside *Y1).

I'm not sure if it's of interest to others and therefore if it's worth the trouble, but I figured I'd suggest it. Thanks very much either way.

User avatar
Klyith
Posts: 594
Joined: Fri, 6. Jan 06, 01:38
x3

Post by Klyith » Mon, 29. Jan 07, 04:06

Whooosh wrote:Would it be possible to script in Roman Numerals?

I just like using them. I'm old fashion.
Yes, I can do roman numerals. As soon as I figure out / find some good code for roman numeral conversion. I quickly looked in google, but most of the examples are annoying when converted into X3 script -- they use lookup tables which are laborious to enter in the script console. I'll try to think of something easier... ;)

I presume you wanted this for the general number counting, the same as *NN and *ZN now but in roman? *RN!

...
I think I'll also fix a cosmetic thing that the "leading zero" option only does one lead zero. If there are 100 or more ships being renames it should pad to three digits with lead zeros.

User avatar
Klyith
Posts: 594
Joined: Fri, 6. Jan 06, 01:38
x3

Post by Klyith » Mon, 29. Jan 07, 04:19

Heh, while I was still ruminating on the roman numerals, another request! Hurrah!
Greg_G wrote:I have a feature request:

I would be very useful to me if the script were to first expand the clipboard expressions (*Y#) before all the other expressions. This way one can save expressions into the clipboard. This is because I tend to need to rename a lot of my ships one at a time (not in formations or groups, not all of the same class, and all in different sectors) and typing *KMStorage*KX (*CL|*TA|*SC) for each ship is rather tedious.

Obviously it would be important to make sure the user never caused a loop (e.g. putting *Y1 inside *Y1).
Yes, that is a good idea. Useful, logical, and a great time saver for the lazy. And the really stupid thing is that when I was first implementing the clipboards, my initial method would have had this ability by default. But I never thought about it, so I changed to a different method without knowing what I lost!
I'm not sure if it's of interest to others and therefore if it's worth the trouble, but I figured I'd suggest it. Thanks very much either way.
It's on tap. Hey, if I'm gonna do roman numerals, I'm gonna do this! (Heh Heh Heh no offense Whoosh! ;) )

User avatar
Tempelaars24
Posts: 121
Joined: Fri, 5. Jan 07, 14:32
x3ap

Post by Tempelaars24 » Mon, 29. Jan 07, 04:51

Could we get a rename target feature?

Greg_G
Posts: 110
Joined: Tue, 26. Apr 05, 19:15
xr

Post by Greg_G » Tue, 30. Jan 07, 04:14

I have a thought on solving the roman numerals option (I don't personally have any use for this feature, but I just thought I'd help out if I could). My idea is pretty awful from a proper programming point of view, but easy from a "typing" it into the script editor POV. You could use lookup tables, but use a T File for that purpose. So lets say you put XXIV as the text for ID=24. The script engine would just feed the number you want into the text ID. So the script engine side of it would be a breeze. The bad side is you'd have a heinously large t file to go up to 999 (just MOD 1000 for this part and /1000 for the number of Ms).

However, I think I have a good way to make this more reasonable since 999 t file entries is absurd. So, have a lookup entry for each of 1,2,3,4,5,6,7,8,9 and one for each of 10,20,30,40,50,60,70,80,90 and one for each of 100,200,300,400,500,600,700,800,900. Then you can piece together the full number from the pieces with lots of use of divide and modulus, of course. That would mean just 30 t file IDs total.

For example: 2124 using all integer math...
(2124 / 1000)=2 ... so 2 Ms
for the rest we'll use 2124 MOD 1000 = 124...
(124 / 100) = 1 ... 1 in hundreds lookup = C
(124 MOD 100)/10 = 2 ... 2 in tens lookup = XX
(124 MOD 10) = 4 ... 4 in ones lookup = IV
so stick 'em all together... 2124 becomes MMCXXIV

I haven't dealt with Roman numerals in years, so maybe I'm forming them wrong in my mind and might even be using the wrong letters in my example. So everything I just said may be way off the mark. :)

Also, I regret that I have another request. :oops: Is there any chance of enhancing the *ZN such that I can choose the number from which it starts? This would be terribly useful for me. Even if I had to put the number in a preselected clipboard entry (like *Y9) instead of in the actual expression, it'd be well worth it.

Either way, this script, as it is, has changed my gameplay experience so much for the better. I can actually find the ships I want quickly in my ships listing. I can't tell you how much effort and annoyance this is saving me! Thanks!

Edit: Of course, you could also vastly simplify the roman numerals option by limiting it from 1-99 or 1-9. I don't know how many people need a ship name Barracuda MMCXXIV. :twisted:

User avatar
Klyith
Posts: 594
Joined: Fri, 6. Jan 06, 01:38
x3

Post by Klyith » Tue, 30. Jan 07, 06:12

Tempelaars24 wrote:Could we get a rename target feature?
Well, the reasonable way to do that would be with a hotkey. Unfortunately hotkeys can't get take additional input, so it would have to be a pre-defined name. Something similar to how the clipboard works could do that... I'll look into this.
Greg_G wrote:I have a thought on solving the roman numerals option
<snip>
Yep, your modulus division idea is about what I was thinking of. But it seems now that the standard compsci example method (which uses subtraction) will work well, I just use a T file to define the array instead of inputting it to the editor.
Greg_G wrote:Also, I regret that I have another request. :oops: Is there any chance of enhancing the *ZN such that I can choose the number from which it starts? This would be terribly useful for me. Even if I had to put the number in a preselected clipboard entry (like *Y9) instead of in the actual expression, it'd be well worth it.
Hmm. Hmmmmmm. :idea: Yes. I can do that, and it won't need to use clipboard (which is a string anyway so hard to use that way). It will be *SN# for the starting number. The only tricky thing is that you will have to put it at the end of your rswe input.
Either way, this script, as it is, has changed my gameplay experience so much for the better. I can actually find the ships I want quickly in my ships listing. I can't tell you how much effort and annoyance this is saving me! Thanks!
Oh stop, I'm blushing. :oops: :) Don't stop!

Greg_G
Posts: 110
Joined: Tue, 26. Apr 05, 19:15
xr

Post by Greg_G » Tue, 30. Jan 07, 10:09

Klyith wrote:Hmm. Hmmmmmm. :idea: Yes. I can do that, and it won't need to use clipboard (which is a string anyway so hard to use that way). It will be *SN# for the starting number. The only tricky thing is that you will have to put it at the end of your rswe input.
Alrighty thanks :), but let me run something by you. If the issue is knowing where the number stops and where the regular text begins (which could itself be a number, of course), instead of terminating on the end of the input, how about if there were another expression to terminate the number, such as *SX (kindof like *KX for colors). Then if the substring between those two expressions doesn't convert properly into a number by the string->number function, it could just use zero or one.

It's just a thought in case that was the problematic issue. Beggars can't be choosers and even the method you stated would be quite helpful. Thanks again.

User avatar
Gazz
Posts: 13244
Joined: Fri, 13. Jan 06, 16:39
x4

Post by Gazz » Tue, 30. Jan 07, 11:43

So... in line 26 there could be another snippet of code that - IF the expression was "*SN" - will fetch the number string up to the next "*". The last * is discarded, the number parsed and added to the expression so the system remains intact without adding any hacks.
*SN only has to be checked for partial string in the parsing section.
My complete script download page. . . . . . I AM THE LAW!
There is no sense crying over every mistake. You just keep on trying till you run out of cake.

User avatar
Klyith
Posts: 594
Joined: Fri, 6. Jan 06, 01:38
x3

Post by Klyith » Tue, 30. Jan 07, 23:47

Greg_G wrote:If the issue is knowing where the number stops and where the regular text begins (which could itself be a number, of course), instead of terminating on the end of the input, how about if there were another expression to terminate the number, such as *SX (kindof like *KX for colors).
Yeah, that was kinda the problem that I was thinking about. But now that I'm not half asleep I realize that putting it as the end is stupid. I want to know what the starting number will be before I encounter one of the regular number expressions! Duuuuh. I have the perfect solution.

Here is how it will work: blahblah*SN42*NNwhatever
That gives you numbers starting at 42, and whatever other text. *SN and the number must be directly before the other number expression. It is supplemental to NN, ZN, or RN, and does nothing by itself. So you can have the start of your count be 7, 07, or VII (and then continue up from there).
Gazz wrote:*SN only has to be checked for partial string in the parsing section.
I want to keep the star parsing loop just for the stars, personally. The other loop has the giant if block for detecting expressions, it helps keep speed up.

Post Reply

Return to “X³: Reunion - Scripts and Modding”