[AL Plugin] Remove Prefix "Your" from Player Property

The place to discuss scripting and game modifications for X³: Terran Conflict and X³: Albion Prelude.

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

User avatar
Graxster
Posts: 815
Joined: Sat, 14. Oct 06, 01:01
x3tc

[AL Plugin] Remove Prefix "Your" from Player Property

Post by Graxster » Tue, 25. Nov 08, 08:22

Al Plugin: Auto-Rename Player Property

My first AL Plugin script, yay! :D Big thanks to LV for adding copious amounts of comments to his Medusa Rapid Fire Missile Interface AL Plugin script. Couldn't have figured it out without those. Thanks LV!

Anyway... this little AL Plugin will automatically rename all your ships and stations, removing the prefix "Your" from the names. It defaults to ON when you load your save. If you want to turn it off, go to Gameplay > Artificial Life Settings. It checks all your ships and stations once every 5 seconds or so, so you will see "Your" once in a while, but not for very long. Enjoy!

-Grax

SPK

Image

RAR Archive

Image

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

Post by Gazz » Tue, 25. Nov 08, 13:19

Have you considered making this a simple text file hack like your last?
This should be even more effective and without any overhead or background tasks.
It wouldn't work on existing objectss, of course.
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
Graxster
Posts: 815
Joined: Sat, 14. Oct 06, 01:01
x3tc

Post by Graxster » Tue, 25. Nov 08, 18:41

That was my first idea, but the game didn't like me playing around with that stuff. I was able to get to a point where ships didn't have "Your", but when I attempted stations, any station built had no name at all. Tried about 6 different ways to get it to work, all with no success. Gave up and wrote this instead. Adding "Your" is a hardcoded event, so if it doesn't get what it's expecting, it wigs out, I guess. I'll look at it again some other time.

-Grax

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

Post by Gazz » Tue, 25. Nov 08, 19:41

Awell. I use a global renaming script anyway so I was just curious. =)
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
Krewzur
Posts: 725
Joined: Mon, 16. Jun 08, 20:14
x4

[SCRIPT] Custom prefix - HELP

Post by Krewzur » Thu, 18. Dec 08, 04:45

I want to make a script that allows you to use a custom prefix for your ships, and automatically rename them for you.

I'm not talking about the other scripts that automatically add the name of the ships homebase or type of factory it's assigned to or anything like that.

I want the script to prompt you for a prefix that you type in and the script inserts it into the names of all your ships

e.g.
I buy 10 Scimitars, they're all called "Your Scimitar".
I want it to auto rename them all to something like "EireCo Scimitar".

So the names will be like the names of the ships from NPC companies eg "TerraCorp Mercury" or "Strong Arms Mamba".

I only want the script to rename ships as station names may be different, like a ship may use a shorter name or abbreviation while the station uses a full name. So i'd prefer if station names are untouched.

If anyone can help me make this script, or point me to an existing one i'd appreciate it.

Thank in advance.
Corsair 400c // Intel i7 8700k // H100i v2 // ASUS Maximus X Code // ASUS 1080ti Strix OC // 2x8GB Corsair Vengeance 3200MHz // Samsung 960 Evo 250GB // 960GB SanDisk Ultra II // Corsair RM850i

User avatar
Nividium
Posts: 695
Joined: Tue, 21. Aug 07, 01:31

Post by Nividium » Thu, 18. Dec 08, 11:38

Script a.temp
Version: 0
for Script Engine Version: 42

Description
Description
Arguments
1: prefix , String , 'type in Prefix'
Source Text

001 $ship.array = get ship array: of race Player class/type=Moveable Ship
002 $ship.array.size = size of array $ship.array
003 while $ship.array.size > 0
004 |dec $ship.array.size =
005 |$ship = $ship.array[$ship.array.size]
006 |$wtc = $ship -> get ware type code of object
007 |$new.name = $prefix + ' ' + $wtc
008 |$ship -> set name to $new.name
009 @ |= wait 1 ms
010 end
011 return null

User avatar
Krewzur
Posts: 725
Joined: Mon, 16. Jun 08, 20:14
x4

Post by Krewzur » Thu, 18. Dec 08, 19:10

Thanks Nividium.

How can i link this to the ship command menu. There is a tutorial for making commands somewhere ain't there?
Corsair 400c // Intel i7 8700k // H100i v2 // ASUS Maximus X Code // ASUS 1080ti Strix OC // 2x8GB Corsair Vengeance 3200MHz // Samsung 960 Evo 250GB // 960GB SanDisk Ultra II // Corsair RM850i

User avatar
Neven87
Posts: 144
Joined: Fri, 2. Dec 05, 11:40
x3tc

Post by Neven87 » Thu, 18. Dec 08, 23:17

for those of us who scripting retarded where would i throw this?

jlehtone
Posts: 17279
Joined: Sat, 23. Apr 05, 21:42
x4

Re: [SCRIPT] Custom prefix - HELP

Post by jlehtone » Thu, 18. Dec 08, 23:29

amurph0 wrote:I want to make a script that allows you to use a custom prefix for your ships, and automatically rename them for you.
Rather than reinventing wheel, take an exiting solution and either ask the author to make it more versatile or adjust it yourself. Threads merged in hopes of creating a tiny bit of synergy.

User avatar
Nividium
Posts: 695
Joined: Tue, 21. Aug 07, 01:31

Post by Nividium » Fri, 19. Dec 08, 01:20

amurph0 wrote:Thanks Nividium.

How can i link this to the ship command menu. There is a tutorial for making commands somewhere ain't there?
To create and link a command to a script, you need to create a t-file and a setup script. The t-file creates the button ie command that shows up on a ships command menu and the setup script links the command to the main script or points to it for execution.

Your t-file should contain the following code: (substitute the <t id with one that is available within the "custom", "special" or "general command slots etc, see list). Then save the t-file, check for an available number in the list ie: 7095-L044.xml.

Code: Select all

<?xml version="1.0" encoding="UTF-8"?>
<language id="44">

<!-- Setup Name Prefix Command Button Slot -->
                <page id="2008" title="Script Object Commands" descr="">
		<t id="857">COMMAND_NAME_PREFIX</t>
	</page>

	<page id="2010" title="Script Cmd Names" descr="">
		<t id="857">Name Prefix</t>
	</page>

	<page id="2011" title="Script Cmd Shorts" descr="">
		<t id="857">NP</t>
	</page>

	<page id="2022" title="Command Info" descr="">
		<t id="857">This area is used for a description text for when the player presses the i key.  Put what you want in here.\n</t>
	</page>
</language>
Your setup file needs to point to your main script and uses the t-file to bind the command button to your main script. So, put in something like this: (then save the file as setup.name.prefix)

Code: Select all

001   load text: id=7095
002   global script map: set: key=COMMAND_TYPE_GENERAL_57, class=Moveable Ship, race=Player, script='my.main.script.file.name', prio=0
003   set script command upgrade: command=COMMAND_TYPE_GENERAL_57  upgrade=[true]  
004   return null
Last edited by Nividium on Sun, 21. Dec 08, 15:18, edited 1 time in total.

User avatar
Krewzur
Posts: 725
Joined: Mon, 16. Jun 08, 20:14
x4

Post by Krewzur » Fri, 19. Dec 08, 02:56

Nividium wrote:Script a.temp
Version: 0
for Script Engine Version: 42

Description
Description
Arguments
1: prefix , String , 'type in Prefix'
Source Text

001 $ship.array = get ship array: of race Player class/type=Moveable Ship
002 $ship.array.size = size of array $ship.array
003 while $ship.array.size > 0
004 |dec $ship.array.size =
005 |$ship = $ship.array[$ship.array.size]
006 |$wtc = $ship -> get ware type code of object
007 |$new.name = $prefix + ' ' + $wtc
008 |$ship -> set name to $new.name
009 @ |= wait 1 ms
010 end
011 return null
I'm having trouble with lines 005 and 007. I don't know how to enter $ship.array[$ship.array.size]

And the + ' ' + in line 007

Both are giving Syntax error or somthing
Corsair 400c // Intel i7 8700k // H100i v2 // ASUS Maximus X Code // ASUS 1080ti Strix OC // 2x8GB Corsair Vengeance 3200MHz // Samsung 960 Evo 250GB // 960GB SanDisk Ultra II // Corsair RM850i

User avatar
Nividium
Posts: 695
Joined: Tue, 21. Aug 07, 01:31

Post by Nividium » Fri, 19. Dec 08, 04:32

amurph0 wrote: I'm having trouble with lines 005 and 007. I don't know how to enter $ship.array[$ship.array.size]

And the + ' ' + in line 007

Both are giving Syntax error or somthing
From within the Script Editor go to [General Commands] [Arrays] Then look at the 2nd command on list ie:

<RetVar/If><Var/Array>[<Var/Number>]

For the line 007, just use the space bar to insert a blank line. The script editor will add the ' ' all by itself to indicate it is a string. Use the <string> there to insert the blank spacer line.

User avatar
Krewzur
Posts: 725
Joined: Mon, 16. Jun 08, 20:14
x4

Post by Krewzur » Fri, 19. Dec 08, 18:39

Thanks again Nividium
Corsair 400c // Intel i7 8700k // H100i v2 // ASUS Maximus X Code // ASUS 1080ti Strix OC // 2x8GB Corsair Vengeance 3200MHz // Samsung 960 Evo 250GB // 960GB SanDisk Ultra II // Corsair RM850i

Sticks
Posts: 215
Joined: Thu, 29. Nov 07, 16:35
x4

Post by Sticks » Sun, 21. Dec 08, 14:30

Hi, can you upload this script please? I'm to dumb to write it myself ...

User avatar
Krewzur
Posts: 725
Joined: Mon, 16. Jun 08, 20:14
x4

Post by Krewzur » Sun, 21. Dec 08, 19:26

Corsair 400c // Intel i7 8700k // H100i v2 // ASUS Maximus X Code // ASUS 1080ti Strix OC // 2x8GB Corsair Vengeance 3200MHz // Samsung 960 Evo 250GB // 960GB SanDisk Ultra II // Corsair RM850i

Post Reply

Return to “X³: Terran Conflict / Albion Prelude - Scripts and Modding”