specific color for abandoned ship???

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

Post Reply
Archaryon
Posts: 6
Joined: Tue, 30. Apr 13, 18:02

specific color for abandoned ship???

Post by Archaryon » Sat, 4. May 13, 13:36

Hi,

is there a script to have name of abandoned ship in a different color in the sector map menu??

I know that with X3TC XTC (and its scripts included), the abandoned ships appeared in blue, which was convenient to identify them, but I play with X3AP XRM right now and I don't have this "option"

User avatar
Lord Dakier
Posts: 3243
Joined: Fri, 8. Dec 06, 13:45
x4

Post by Lord Dakier » Sat, 4. May 13, 14:23

I imagine you can create a script for this just like X-Tended did. I don't know personally though.

User avatar
apricotslice
Posts: 14129
Joined: Sun, 16. May 04, 13:01
x4

Post by apricotslice » Thu, 16. May 13, 15:32

In my mod, they appear in orange. I'd have to look to see which script does it, as it was a long time ago it was written for me.

Its not inherently difficult to do though, using a text file.

edit : found it. This checks the sector and automatically changes all abandonned ships to an orange colour. You can run it manually, or call it from a script you do run regularly.

Code: Select all

001   $PageID = 9915
002   load text: id=$PageID
003   
004   $array.ship =  get ship array: of race Neutral Race class/type=Ship
005   $size =  size of array $array.ship
006   
007   while $size > 0
008   |dec $size = 
009   |$ship = $array.ship[$size]
010   |$is.renamed = $ship -> get local variable: name='AS.Is.Renamed'
011   |if $is.renamed != [TRUE]
012   ||$ship -> set local variable: name='AS.Is.Renamed' value=[TRUE]
013   ||$old.name = $ship -> get name
014   ||$new.name = sprintf: pageid=$PageID textid=100, $old.name, null, null, null, null
015   ||$ship -> set name to $new.name
016   |end
017   |skip if not $size == ( $size / 20 ) * 20
018 @ ||= wait 100 ms
019   end
020   return null
021   
022   
023   
And the text file is ....

Code: Select all

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

 
 <page id="9915" title="Messages" descr="Info Nom">

    <t id="100">\033O%s\033x</t>
  
 </page>
</language>

User avatar
joelR
Posts: 2008
Joined: Mon, 9. Jul 07, 23:33
x3tc

Post by joelR » Thu, 16. May 13, 19:25

@apricotslice

Are there any rules to naming a script? Can I name the script to whatever I want?

Thanks for this by the way.

Vayde
Posts: 849
Joined: Fri, 6. Feb 04, 21:02
x3tc

Post by Vayde » Thu, 16. May 13, 20:03

Perhaps you could link it to fire on chage sector?
Still life in the old dog yet...

qwizzie
Posts: 562
Joined: Thu, 1. Jun 06, 12:17
x4

Post by qwizzie » Thu, 16. May 13, 22:20

very nice script Apricotslice .. thanks for putting it in this post.

For my own use i changed ''Ship'' to ''Moveable Ship'' in line 004 so astronauts will be excluded from the ''paintjob'' :)

Code: Select all

004   $array.ship =  get ship array: of race Neutral Race class/type=Ship

To get your script (which i named ''Colored.xml'') going on in the background you could use for example this MD code
(which needs to be put in the directory folder) :

Code: Select all


<?xml version="1.0" encoding="ISO-8859-1" ?>

<?xml-stylesheet href="director.xsl" type="text/xsl" ?>
<director name="Colored Claimable Ships" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="director.xsd">
  
<documentation>
<author name="qwizzie" />
<content name="Colored Claimable Ships" description="Installs Colored Claimable Ships" />
<version number="1.0" date="16/05/13" status="active" />
</documentation>
  
<cues>
<cue name="Colored Claimable Ships">
      
<condition>
<check_all>
<check_age value="{player.age}" min="1s" />
</check_all>
</condition>
<action>
<do_all>
          
<run_script script="Colored" />

<cues>
<cue name="restart MD">
<timing>
<time exact="180s" comment="180 sec delay"/>
</timing>
</cue>
</cues>
                             
 <reset_cue cue="Colored Claimable Ships"/>
 
 </do_all>
      
</action>
    
</cue>
  
</cues>

</director>


User avatar
apricotslice
Posts: 14129
Joined: Sun, 16. May 04, 13:01
x4

Post by apricotslice » Fri, 17. May 13, 03:58

The script was written originally by Logain Abler, for a specific situation. I call it from various places, such as my jump to derelict script, so that the first thing that happens after jumping to a new sector with a derelict ship in it, is that all such ships turn orange on the nav map.

I deliberately left astronuts in the script, so I could see immediately how many there were, since for a long time, I used to collect them all.

User avatar
joelR
Posts: 2008
Joined: Mon, 9. Jul 07, 23:33
x3tc

Post by joelR » Fri, 17. May 13, 04:19

Ignore my previous question. I see why the script didnt work. I was copy/pasting your code into notepad++ and saving it as an XML instead of using the in game editor.

This has been a good lesson in scripting the game which I have been putting off!

User avatar
apricotslice
Posts: 14129
Joined: Sun, 16. May 04, 13:01
x4

Post by apricotslice » Fri, 17. May 13, 04:59

Sorry, I missed your question.

You can name scripts anything you like, but setup at the beginning is only for scripts that run on startup, and ! on the beginning refers to egosoft core scripts.

The only way you can cut and paste code is to use excriptor or the other external script editor. Otherwise, yes, you need to use the internal editor to script in each line of code from scratch. Major pain, but as you said, it is a lesson in scripting. :)

User avatar
joelR
Posts: 2008
Joined: Mon, 9. Jul 07, 23:33
x3tc

Post by joelR » Fri, 17. May 13, 08:26

apricotslice wrote:Sorry, I missed your question.

You can name scripts anything you like, but setup at the beginning is only for scripts that run on startup, and ! on the beginning refers to egosoft core scripts.

The only way you can cut and paste code is to use excriptor or the other external script editor. Otherwise, yes, you need to use the internal editor to script in each line of code from scratch. Major pain, but as you said, it is a lesson in scripting. :)
I keep getting this error in Exscriptor when I try to save the script. Any idea why?

Saving file...
Save failed because of compilation errors - please compile again
Save failed due to compilation errors!
- Error on line 4 - Unrecognised symbol in expression: get
- Error on line 8 - Unrecognised symbol in expression: dec
- Error on line 9 - Error in expression: expected a number, [constant], 'string', {literal}, null, or (subexpression) but found |.
- Error on line 10 - Unrecognised symbol in expression: get
- Error on line 11 - Error in expression: expected a number, [constant], 'string', {literal}, null, or (subexpression) but found |.
- Error on line 12 - Unrecognised symbol in expression: set
- Error on line 13 - Unrecognised symbol in expression: get
- Error on line 14 - Unrecognised symbol in expression: sprintf
- Error on line 15 - Unrecognised symbol in expression: set
- Error on line 16 - Unrecognised symbol in expression: end
- Error on line 17 - Error in expression: expected a number, [constant], 'string', {literal}, null, or (subexpression) but found |.
- Error on line 18 - Unrecognised symbol in expression: wait

Warnings:
Variable array.ship is being used on line 5 before being assigned to.

User avatar
apricotslice
Posts: 14129
Joined: Sun, 16. May 04, 13:01
x4

Post by apricotslice » Fri, 17. May 13, 08:29

Can you do a screen dump of what excripter is showing ?

Easier to help when we can see what you see.

User avatar
joelR
Posts: 2008
Joined: Mon, 9. Jul 07, 23:33
x3tc

Post by joelR » Fri, 17. May 13, 08:44

apricotslice wrote:Can you do a screen dump of what excripter is showing ?

Easier to help when we can see what you see.
Heres a link:

http://i.imgur.com/LzaTTdm.png

User avatar
apricotslice
Posts: 14129
Joined: Sun, 16. May 04, 13:01
x4

Post by apricotslice » Fri, 17. May 13, 08:47

No idea. That looks fine to me.

User avatar
joelR
Posts: 2008
Joined: Mon, 9. Jul 07, 23:33
x3tc

Post by joelR » Fri, 17. May 13, 09:14

Alright. Thanks anyhow. Must be something buggy with exscriptor.

User avatar
DrBullwinkle
Posts: 5715
Joined: Sat, 17. Dec 11, 01:44
x3tc

Post by DrBullwinkle » Fri, 17. May 13, 10:16

Did you copy and paste that code into Exscriptor?

It looks as though you have tab characters (which are not allowed).

User avatar
joelR
Posts: 2008
Joined: Mon, 9. Jul 07, 23:33
x3tc

Post by joelR » Fri, 17. May 13, 17:06

DrBullwinkle wrote:Did you copy and paste that code into Exscriptor?

It looks as though you have tab characters (which are not allowed).
I did!

That must be it. I will go back and see if there are any.

Thanks.

User avatar
joelR
Posts: 2008
Joined: Mon, 9. Jul 07, 23:33
x3tc

Post by joelR » Fri, 17. May 13, 17:36

Ok removing the tab characters got rid of most of the errors but im still getting two errors for lines 4 and 17:

Code: Select all

- Error on line 4 - Unrecognised symbol in expression: get
- Error on line 17 - Error in expression: expected a number, [constant], 'string', {literal}, null, or (subexpression) but found not.
These are the lines in question:

Code: Select all


Line 4- $array.ship = get ship array: of race Neutral Race class/type=Ship

and

Line 17- skip if not $size == ( $size / 20 ) *20
Anything obvious? Have I used the correct characters?

Vayde
Posts: 849
Joined: Fri, 6. Feb 04, 21:02
x3tc

Post by Vayde » Fri, 17. May 13, 21:55

Why not take this a step further and have all ships coloured according to race? It would make at a glance recognition a whole lot easier.

I think, way back, there were coloured frieght menu's available, would writing the code to colour all ships be a huge task?
Still life in the old dog yet...

User avatar
DrBullwinkle
Posts: 5715
Joined: Sat, 17. Dec 11, 01:44
x3tc

Post by DrBullwinkle » Fri, 17. May 13, 22:17

Coloring all ship names is not so much difficult as it is prone to conflicts. The above script could easily be adapted. However, scripts that auto-rename ships may not work with colored names (or may just overwrite the colored names).

Updating new ships when they are created is slightly trickier. It requires either a signal_changesector script or a potentially performance-affecting global task.

The color-coded freight menu mod is cool but conflicts with something else that I use... cannot recall what off the top of my head. I think it was the packaging of the mod itself that caused the problem, because I use the technique in my own current game (to give me hints about some of the less-common missiles).

Anyhow, it should be easy enough to do if you want it.

qwizzie
Posts: 562
Joined: Thu, 1. Jun 06, 12:17
x4

Post by qwizzie » Fri, 17. May 13, 23:53

is it happens i was yesterday also thinking in that direction.. which resulted in this script

[SCRIPT] X3 TC / AP : Sectormap Revamped 1.0 dd 17-05-2013
http://forum.egosoft.com/viewtopic.php?t=336711

to OP with regards to coloring claimable ships :

[SCRIPT] X3 TC / AP : Colored Claimable Ships dd 17-05-2013
http://forum.egosoft.com/viewtopic.php?t=336717

Post Reply

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