[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: Moderators for English X Forum, Scripting / Modding Moderators

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

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

Post by Graxster » Tue, 25. Nov 08, 07: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

[ external image ]

RAR Archive

[ external image ]

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

Post by Gazz » Tue, 25. Nov 08, 12: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: 817
Joined: Sat, 14. Oct 06, 01:01
x3tc

Post by Graxster » Tue, 25. Nov 08, 17: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: 13244
Joined: Fri, 13. Jan 06, 16:39
x4

Post by Gazz » Tue, 25. Nov 08, 18: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, 03: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: 800
Joined: Tue, 21. Aug 07, 01:31

Post by Nividium » Thu, 18. Dec 08, 10: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, 18: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, 10:40
x3tc

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

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

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

Re: [SCRIPT] Custom prefix - HELP

Post by jlehtone » Thu, 18. Dec 08, 22: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: 800
Joined: Tue, 21. Aug 07, 01:31

Post by Nividium » Fri, 19. Dec 08, 00: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, 14: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, 01: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: 800
Joined: Tue, 21. Aug 07, 01:31

Post by Nividium » Fri, 19. Dec 08, 03: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, 17: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: 216
Joined: Thu, 29. Nov 07, 15:35
x4

Post by Sticks » Sun, 21. Dec 08, 13: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, 18: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

User avatar
Sandalpocalypse
Posts: 4447
Joined: Tue, 2. Dec 03, 22:28
x4

Post by Sandalpocalypse » Sun, 21. Dec 08, 19:04

the remove-Your script is constantly at war with SEWN which forces satellites to be named Your Advanced Satellite [SEWN]
Irrational factors are clearly at work.

tamtam77
Posts: 31
Joined: Fri, 17. Apr 09, 09:21

Post by tamtam77 » Wed, 13. May 09, 16:36

usefull script. I use it with commercial agent 2.5 and in IN HUB menu list of Fabrics is still 'Yours' (.

frijazz
Posts: 63
Joined: Fri, 31. Mar 06, 21:52
x3tc

Post by frijazz » Thu, 14. May 09, 10:13

I was about to say the same. Finally my financial situation is so healthy that I've started building complexes to supply the universe. I noticed that the prefix *your* automatically is added to the stations when joining them in the complex.

User avatar
Khensu
Posts: 110
Joined: Wed, 28. Oct 09, 09:42
x3tc

Post by Khensu » Wed, 4. Nov 09, 10:52

cant dl the custom nameing version :(

can u host it to another site?

unrockable
Posts: 25
Joined: Wed, 18. Feb 04, 18:58
x4

Post by unrockable » Sun, 8. Nov 09, 01:59

I tried to change the script to my needs, but i somehow don`t get it to work. Can anybody help me? (Probably something wrong with the "if $ship == Class/Object"-conditions.)

Code: Select all

001   $plugin.data = get global variable: name=$plugin.ID
002   if not $plugin.data
003   |$plugin.data =  array alloc: size=2
004   |set global variable: name=$plugin.ID value=$plugin.data
005   |$plugin.data[0] = 0
006   |$plugin.data[1] = [TRUE]
007   end
008   if $plugin.event == 'init' OR $plugin.event == 'reinit'
009   |al engine: set plugin $plugin.ID description to 'Auto-Rename Player Property'
010   |$timer = 60
011   |al engine: set plugin $plugin.ID timer interval to $timer s
012   else if $plugin.event == 'isenabled'
013   |$retvar = $plugin.data[1]
014   |return $retvar
015   else if $plugin.event == 'start'
016   |$plugin.data[1] = [TRUE]
017   else if $plugin.event == 'stop'
018   |$plugin.data[1] = [FALSE]
019   else if $plugin.event == 'timer'
020   |if $plugin.data[1]
021   ||$ship.array =  get ship array: of race Player class/type=Schiff
022   ||$n =  size of array $ship.array
023   ||while $n
024   |||dec $n = 
025   |||$ship = $ship.array[$n]
026   |||$name = $ship -> get name
027   |||$sub =  get substring of $name offset=0 length=3
028   |||if $sub == 'Ihr'
029   ||||$sub1 =  get substring of $name offset=4 length=99
030   ||||if $ship == TL
031   |||||$newname = 'TL' + ' ' + $sub1
032   |||||$ship -> set name to $newname
033   ||||else if $ship == M1
034   |||||$newname = 'M1' + ' ' + $sub1
035   |||||$ship -> set name to $newname
036   ||||else if $ship == M2
037   |||||$newname = 'M2' + ' ' + $sub1
038   |||||$ship -> set name to $newname
039   ||||else if $ship == M3
040   |||||$newname = 'M3' + ' ' + $sub1
041   |||||$ship -> set name to $newname
042   ||||else if $ship == M4
043   |||||$newname = 'M4' + ' ' + $sub1
044   |||||$ship -> set name to $newname
045   ||||else if $ship == M5
046   |||||$newname = 'M5' + ' ' + $sub1
047   |||||$ship -> set name to $newname
048   ||||else if $ship == M6
049   |||||$newname = 'M6' + ' ' + $sub1
050   |||||$ship -> set name to $newname
051   ||||else if $ship == M7
052   |||||$newname = 'M7' + ' ' + $sub1
053   |||||$ship -> set name to $newname
054   ||||else if $ship == M8
055   |||||$newname = 'M8' + ' ' + $sub1
056   |||||$ship -> set name to $newname
057   ||||else if $ship == TS
058   |||||$newname = 'TS' + ' ' + $sub1
059   |||||$ship -> set name to $newname
060   ||||else if $ship == TP
061   |||||$newname = 'TP' + ' ' + $sub1
062   |||||$ship -> set name to $newname
063   ||||else if $ship == TM
064   |||||$newname = 'TM' + ' ' + $sub1
065   |||||$ship -> set name to $newname
066   ||||else if $ship == Schiff
067   |||||$newname = $sub1
068   |||||$ship -> set name to $newname
069   ||||end
070   |||end
071   ||end
072   ||$station.array =  get station array: of race Player class/type=Station
073   ||$n =  size of array $station.array
074   ||while $n
075   |||dec $n = 
076   |||$station = $station.array[$n]
077   |||$name = $station -> get name
078   |||$sub =  get substring of $name offset=0 length=3
079   |||if $sub == 'Ihr'
080   ||||$sub1 =  get substring of $name offset=4 length=99
081   ||||$station -> set name to $sub1
082   |||end
083   ||end
084   |end
085   end
086   return null

Post Reply

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