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

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

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

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

Post by Greg_G » Tue, 30. Jan 07, 05: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: 575
Joined: Fri, 6. Jan 06, 02:38
x3

Post by Klyith » Tue, 30. Jan 07, 07: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, 11: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: 12430
Joined: Fri, 13. Jan 06, 17:39
x3tc

Post by Gazz » Tue, 30. Jan 07, 12: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: 575
Joined: Fri, 6. Jan 06, 02:38
x3

Post by Klyith » Wed, 31. Jan 07, 00: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.

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

Post by Greg_G » Wed, 31. Jan 07, 01:53

Klyith wrote:It is supplemental to NN, ZN, or RN, and does nothing by itself.
Ah, very good plan! Sounds great.

Puruco
Posts: 527
Joined: Tue, 6. Dec 05, 01:09
x3

Post by Puruco » Wed, 31. Jan 07, 16:41

Hi all: Klyth, if I want to rename a single ship, even if it is part of a formation. How I do that?

thanks....

User avatar
Klyith
Posts: 575
Joined: Fri, 6. Jan 06, 02:38
x3

Post by Klyith » Thu, 1. Feb 07, 00:32

Puruco wrote:Hi all: Klyth, if I want to rename a single ship, even if it is part of a formation. How I do that?
Select it on the map or property screen, press the button you have bound to "rename object" (default 'm'). :P OK, maybe that wasn't what you wanted to know. ;)

RSwE was never really intended for single ship renaming, it's about batch jobs. Over time I've added options for more granular selection of ships... Version 1.4 (this Friday I hope) will have a rename target hotkey, but it won't be quite like the standard rename since you will need to pre-set the name pattern.

Otherwise you have to figure out some way to get the ship "alone", or else rename the whole group and then "undo" the changes to the rest of the ships.

Puruco
Posts: 527
Joined: Tue, 6. Dec 05, 01:09
x3

Post by Puruco » Thu, 1. Feb 07, 16:24

:D Thanks Klyth, will wait for single ship update....

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

Post by Greg_G » Thu, 1. Feb 07, 20:52

While it's obvious the original intention was for batch renaming, let me tell you it's become critical to some of us (well...me :p) for single ship renaming. I've only used batch renaming twice while I've done single ship renaming dozens of times now. So far I havent had a problem with naming individual ships, as I just use the formation renaming on a single ship since I am not far enough along to have any formations. But once I am, I admit a 5th option in the formation renaming "message" for "Single Ship" might be handy.

But, like you said, you can always just maneuver the ship off by itself so it's not a big deal at all.

User avatar
Gazz
Posts: 12430
Joined: Fri, 13. Jan 06, 17:39
x3tc

Post by Gazz » Thu, 1. Feb 07, 22:01

Klyith wrote:
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.
Maybe this is too simple but...
on a $where of 457, the script goes through all the normal moves up to building the ship array.
Then it nukes the pretty array and replaces it with with the contents of
Get Player Tracking Aim.

That's the simplest single object argument you can supply to every script.

Of course you could be eleet and make it work universe wide.
The target object is whatever playership is following because that can only be one object.
= [PLAYERSHIP] -> get formation leader
Just type fast before your ship hits a jump gate! =P

Supplying the object with a "real" argument is too damn tricky to bother.
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: 575
Joined: Fri, 6. Jan 06, 02:38
x3

Post by Klyith » Fri, 2. Feb 07, 01:34

OK, does anyone actually like the idea of a hotkey, when it requires a preset expression string (like the clipboards)? I know most people can't totally rename any ship with just a single rswe string. It is programmed, but now I'm not sure what to do about it. I can take it out if it has no appeal.

I will add single ship renaming to the main command... There are two ways to do it though. Get player target has the limitation that you have to be in the same system. There is also the method of "rename the ship that ran the command", ie you execute from the console of the ship you want to rename. OR I can do both.

I can have 1.4 wrapped up an ready tonight. Then I have a ton of good new ideas (some from or inspired by Gazz's additions) for some new and cooler expressions. 1.5 is going to rock.

User avatar
Klyith
Posts: 575
Joined: Fri, 6. Jan 06, 02:38
x3

Post by Klyith » Fri, 2. Feb 07, 08:00

OK, 1.4... The rundown:
A) There are now three, count 'em three, ways to rename a single ship. You can use the main RSwE command an enter 3 or 4 in the first option box. 3 = rename the ship running the command (ie run it from the console of the ship you want to rename). 4 = renames the player's target.
. Also, there is the hotkey for renaming your target. First you have to set *YT, the same as you set the other clipboards. Then you can pound on that key and it will rename your ships that you target. So if you can think of a good expression that works for most of your ships this may be a big timesaver. If not, don't use it.

B) Clipboards can contain working expressions. You can't put a clipboard in a clipboard, sorry (too much chance of infinite loops).

C) The *RN Roman Numerals and *SN Starting Number expressions. Starting Number works like *SN42*_N to make the other number count expression start at 42. Roman numerals are accurate up to 399 -- after that it just keeps adding 'C's instead of D and M. So if you rename 1000 ships using RN you will have a lot of Cs, and be disappointed. You are also a very silly person for naming 1000 ships with roman numerals.
BTW: Roman numerals are a pain to debug.

D) When using the *ON Old Name feature, it now strips the colors out. Done for a variety of reasons. But as a bonus for reading this entire post, I'll let you in on the new sooper-sekrit easter egg expression: *OC is old name keeping colors. Shhh! Don't tell anyone!

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

Post by Greg_G » Fri, 2. Feb 07, 09:03

Exceptional, Klyith, thank you. I'll be sure to test it out as soon as I can (writing a new script at the moment).

Best regards,
Greg

Puruco
Posts: 527
Joined: Tue, 6. Dec 05, 01:09
x3

Post by Puruco » Fri, 2. Feb 07, 16:45

Thanks Klyith for the update, even that I foumd a way for reneming single ships, the update is a better way and cleaner....thanks again...

Post Reply

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