Creating a Text File


Text file are used to load all text required into the game as well as using command slots and wares

To create a text file, you must first pick an id to use, id's are 4 numbers, usually between 7000 and 9000.
View the egosoft page will list all the text files that are currently being used by scripts, so its usually best to pick one thats not used to avoid conflicts.

Click Here for the text file list

Now you need to create the file itself, the filename is the language id followed by the text id you've chosen, for English, the id is 44
So for the language file id 9000, the filename is 449000.xml and it goes in the x3/t directory, and can edit it in a standard text editor like notepad.
The first line is the file information this can be pretty much the same in all files.

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


This sets the file as an xml file using UTF-8 encoding, UTF-8 is used to allow the special characters from other languages like russian to work.

The next line is the language id, this is the same id that you used to name the file, ie 44 for english

<language id="44">


The rest of the file is set out in page blocks, each page has an id which is used in the script editor to load which block of text to use.
There are various predefined pages to use when adding commands or wares, but if you're just adding some text to be used, then you need to pick an id like you did for the file name.
Again the id's are usually between 7000 and 9000, so its usually best to use the same page id as file id.
So the next line will be the start of your page block

<page id="9000" title="my script text">


The title argument is used mainly for reference and isn't nesesary
Inside the page blocks you have each indivial text entries, each having an id of thier own
These are in t blocks

<t id="1">Some text</t>


Note the closing of the block at the end with the </t>. Like html all tags must be closed.
Finally you need to close the page block

</page>


You can add as many page blocks into the files as you like, at the end of the file you need to close the language block

</language>


So now you've made the text file, this is how the complete file should look


<?xml version="1.0" encoding="UTF-8" ?>
<language id="44">
 <page id="9000" title="my script text">
  <t id="1">Some text</t>
 </page>
</language>

Lastly you need to be able to access these text's from inside the script editor

The first thing you need to do is load the text file into the game for use
This is usually done in a setup file, or it could just be run manually if you prefer
Create a new script and from the general commands, select the command: load id



The only argument is a number, and its the id of the file, in this case, its 9000
So enter 9000 as the number



This is the setup script done, onces its loaded, the text from the file will be loaded
To get some text you can use the "read text" command from the general menu



The first argument is the return value, this is a varible that the text will be stored in, select varible and input the varible name.
For this example, im going to use the varible "message". This will create a new varible as $message and store the text from the file



The next argument is the page id, this is the page block you want to get the text from.
Using the number 9000, will get the text block we added to the text file.
When loading text files, all files will be loaded into memory, so if you have a few files with the same page blocks, they will overright each other.
When getting the text, It will look in all text files that are loaded to find the correct page block.



The file argument is the text id, this is the t id from the file, using the id of 1 for page 9000, will return the text "Some Text"



Now the varible $message should contrain the string "Some Text"
To test this, we can just put it to the logbook
From the logbook commands menu select the write to player logbook command



The only argument is the text to put to the logbook, we will use the varible just created.
select the varible "message" from the list



When this script is run, it will display the text in your logbook

<< Prev (Multiple Varibles)		Next (Using a Command Slot) >>