How to install / manage scripts and mods

The place to discuss scripting and game modifications for X²: The Threat.

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

Locked
User avatar
Burianek
Posts: 2981
Joined: Mon, 29. Dec 03, 03:29
x3tc

How to install / manage scripts and mods

Post by Burianek » Wed, 28. Apr 04, 23:05

This guide is intended for those of us new to scripting / modding for x2. It will attempt to describe how to install and manage your scripts and mods and provide links to important relevant information. It's my intention to make this topic include everything needed to get up and running and installing / removing mods and scripts like an old pro.

I'll update it every once in a while :P

Mod -
anything that changes raw game data and parameters. Examples are altering the speed of your nova, changing the price of the Solar Power Plant, or increasing laser range by a factor of three.

Scripts -
a series of commands that cause something to happen in the X - universe. Written in the proprietary x - scripting language. Can be anything from helpful automation of commonly performed tasks to addition of new missions. Examples are automating the transfer of money between the player account and factories, improved combat AI, or intelligent management of supply freighters.

General installation instructions and lessons learned:
(these may very slightly, but if they do, it should be spelled out in the readme)

Mods -
As of version 1.3 of X2, most mods that you download should be in what is called "packaged form." This means that there are likely several game files that have had their data altered, but for your convenience, these files are compressed into two files, which will be called {name}.cat and {name}.dat, where {name} is the name of the mod. These are sometimes referred to as a .cat/.dat combo. They are also sometimes referred to as only a .dat file, but in any case the .cat file and .dat file work together and must always be installed / removed together and located in the same directory together.

As of version 1.3 of X2, there are two ways to install mods that are packaged. The first way is to place the .cat/.dat combo into a folder called 'mods' located within your X2 main directory. This directory will not exist, you must create it. Make sure you call it mods and not mod. It needs to be plural. Mods installed by locating them in the /mods directory will then be 'selectable' from the X2 startup / splash screen. This is the screen that pops up before the game starts and has options to change graphical performance, player logo, etc. There will be a button called 'select mod package'. When you click on this button, you'll see a list of all of the .cat/.dat combos that you have located in your mods directory. You may highlight one mod, which will take effect when the game loads. The advantage to installation in this fashion is that you can effectively 'turn mods on and off' by selecting them or deselecting them. Note the limitation, however, that you can only have one mod active. This is done to prevent conflicts between mods, but many mods can be used together without conflict. This leads to the second method of installing mods.

The second way to install a mod is to trick the game into thinking it is a patch. Egosoft's method for updating it's game is to release a new .cat/.dat combo with every patch release. These .cat/.dat combos are placed in the main X2 directory and are called 01.cat/.dat 02.cat/.dat etc. These compressed .cat/.dat combos contain all of the new files that need to be read into the game for the patch to take effect. (Where 01.cat/.dat are the very original game files and include everything) The game loads these in order, starting with 01.cat/.dat and working it's way up. In case of conflict, let's say for example 01.dat and 02.dat both contain the file that sets the speed of the nova, the highest numbered version has priority. As of version 1.3 of X2, the highest numbered patch combo is 04.cat/.dat. So for example, with version 1.4 coming up TPs will supposedly not be able to carry XL freight. What will happen is that upon installing the 1.4 patch, a new .cat/.dat combo called 05.cat/.dat will be created in your main X2 directory. Among other things, this compressed .dat file will contain a new version of the file that sets freight carrying capacity. It will, in effect, overwrite the older files so that the changes take place. So back to the subject of mod installation. If you have a mod that you want to install, simply rename it as the highest unused number in the main game directory. The game will think it is a patch and will load it up on game startup. Note that the disadvantage of this method is that it isn't quite as easy to turn these 'on/off'. They will always be loaded unless the files are renamed, deleted, or moved out of the main directory. The advantage is that there are no limits to the number of mods that you can install in this way. However, having multiple mods may lead to conflicts.

You can also run your game in comepletely unpacked mode. This can be very useful if you're planning on making modifications to your game, but not necessary for casual users. If you've unpacked the original egosoft 01 - 04.dat (or whatever) .dat files as per the instructions in this guide, you'll have a bunch of extra files and folders in your X2 directory. These are the raw game files that were "zipped up" in the 01 - 04.dat files. When you boot your game up, the game looks for files to load in this order:
1. Mods placed in the /mods directory and activated using the startup screen.
2. The original 01 - 04.dat files in the X2 main directory.
3. If these have been deleted (or moved is a better solution) then it will run the game off of the unpacked files.
This can be useful to a modder, because using this method, a modder wouldn't need to repackage game files every time they made small changes. The game loads the changes automatically as it is running off of the raw game files which the modder can modify.
(That shouldn't make sense to someone not interested in modding, don't worry about it ;))

Dealing with conflicts -
Most mods make changes to what are called the 'types' files. And most readmes will tell you which types files have been changed. It is perfectly safe to use two mods together if they do not contain the same files. If two mods contain the same types files, they will conflict. The higher numbered mod will have priority. (and for these purposes a mod located in the mods folder and selected using the button has the highest priority) The only way to deal with this is to what is called 'manually merge' the files. This involves taking each instance of the conflicting file and creating a new file which contains all of the changes from each. For example: mod 1 changes the speed of the nova, mod 2 changes the speed of the orinoco. Both mods alter the types/TShips file to do so. Only solution is to create mod 3 which changes the speed of both the nova and orinioco by incorporating both changes into a new TShips file. This can be a pain in the rear. If you're a casual user of mods, and you don't want to learn how to edit them (which is beyond the scope of this primer) your best bet is to plead with the author to do this for you, but don't expect much (anything).

Removing mods -
If it's in the mods directory, deselect it from the startup screen by pressing the original button. Then you can erase the .cat/.dat combo from your mods directory if you want (but not necessary). DO NOT delete the .cat/.dat combo before you deselect it. If you do, the game will look for the file when you try to load the startup screen up and you'll lock up the game. If you've done this, pick another .cat/.dat combo and rename to whatever it was that you deleted and put this 'fake' combo in the mods directory. Then when you load up the startup screen you'll be able to deselect it. (edit 6/4 - this appears to have been corrected, so no worries, delete away :D Deleting the mod file that is currently in use will now reset the game to original mode the next time it is loaded.)
If your mod is applied 'patch style', you may simply delete it or rename it to a non number name to prevent it from loading up on game startup.

Non packaged mods or mods for previous versions of X2 -
My advice here is not to use mods made for previous versions of X2, they can have unpredictable results. If you're an experienced user you don't need this primer. If you aren't, I'd be very careful with old mods. Generally, after a new version of X2 is released, after an initial coding period, most authors will release updated versions of their mods compatible with the new version.

Scripts -
The absolute first thing you need to do to install any unsigned script in your game is to make sure the script editor has been enabled in your game. As of X2 1.3, unsigned scripts will not run if the script editor is not enabled.
To enable the script editor.
http://www.egosoft.com/x2/forum/viewtopic.php?t=17965

Scripts are installed by copying the relevant .xml files to the correct directory. Most files will be the actual scripts and need to be copied to the /scripts directory, but there may be a few text display files which will need to be copied to the /T directory. (pretty sure T stands for text) You'll know these text display files because they will in all cases be named a number. The first two numbers of the file will be 44 for english and 49 for german. These text display files work together with the actual script files located in the /scripts directory, and allow scripts to link to command options from the ship computer among other text display issues.
Here are a few pictures to illustrate:
Installing a script that has all of the .xml files packaged together in the zip
Installing a script where the author has split the .xml files into the correct directories for convenience (these kinds of zips can usually just be extracted to your root X2 directory and they'll install just fine)
(thanks for the pics LV) :)

Once you have the files in the right place, that may be enough, or it may not. Scripts need to be told to run in order to actually run. If the set of scripts that you are installing contains a script that begins with the segment init. or setup. it is run automatically when the game is loaded or when you select 'reinit script caches' from the script editor window. In general, you don't need to do anything more than place these scripts in your scripts folder for them to run correctly the next time you load a saved game. Often times, these scripts are linked to commands in the ship computer, and when you select the appropriate option, the linked script is run. If your script package does not contain an init.*.xml or setup.*.xml script, you may need to run it yourself to get it going. One example of this type of script is the infinite loop script. A good example is the khaak second invasion script by aalaardb. Once you start this type of script running, it runs forever. In order to start this type of script, you need to enter the script editor, find the correct script in the list, highlight it by moving the cursor so that it is selected, and then press 'r' to run the script. (edit 9/10 - with the introduction of the new AL plugins infinite loops should be a thing of the past. Think very carefully before installing a script that describes itself as an infinite loop, there are much better ways to code this now, and the script is going to be clumsy to deal with.)

Dealing with conflicts -
There are a few ways that scripts can conflict.
Certain scripting conflicts may be relatively simple for users to fix, and therefore I'll explain a few things about how to get different scripts to function together if they do happen to conflict without going into detail about script creation. The first thing to note is that in order to view an .xml script, you will need the scripting library file in the same directory as the .xml file you are trying to view. This is the file in your /scripts directory with the .xsl extension. Feel free to copy it to another directory if you want to do your work in a directory other than the /scripts directory. .xml text files in the T directory do not need this library as they contain text only, and not commands.
Most often, a conflict will occur when two scripts both attempt to use the same command number in the ships computer. Scripters try to work together to prevent this, but it still happens. In this case, one command will be available from the commands window, but the other won't exist.
This thread talks about how to fix this.
http://www.egosoft.com/x2/forum/viewtopic.php?t=40500

Removing scripts -
There are several types of scripts. How you go about removing a script varies depending on what type of script it is. In general, scripts are saved in a save game file. It works something like this: When you load up a saved game, the game checks the scripts directory to see if all of the currently running scripts are in the directory. If they aren't there, it creates the files in the scripts directory. For this reason, simply deleting a script from your scripts directory may not be enough to remove it.
There is a quick and dirty way of removing scripts described in this post.
For a more robust method of removing a script, follow these instructions from an older post:


-----------------------
Posted on www.xscripting.com Thursday, January 29 @ Eastern Standard Time by SteelRush
foxtrot359 writes "THINGS YOU SHOULD KNOW FIRST;

The first thing you need to know is that scripts are saved within the save game. So even if you delete the script from the directory the script will still come back when you load a save game, that had the script active.

The second thing is you need to know what files belong to what scripts. That is why it’s very important for scripter to include the file names of all the scripts they are using for there mod, in the read me file.

There are two types of loop script the first one is the deadliest of all loops, meaning that it’s the hardest to get read of. This loop script is manually activated in the script editor and is usually pointing to multiple objects, to control. This type of script cannot be turned off.
The second type of loop script is easier to remove because it uses an init command file script. (init.cmd.name.xml). the init command script is a file that will add/or activate a button command within the game menu, example; buyware for best price, sellware for best price, etc….. These types of commands can be turned off just by selecting none in the command menu.
Standard or non-looping scripts are run once scripts and can be activated manually by using the script editor or by using an init command script which adds a button in the game menu. The type of non-looping script used is up to the scripter.

BEST WAY TO REMOVE SCRIPTS;
1.Open the save game of the script you wish to remove and deactivate any ship or station using the script by selecting the command none.
(You can check to see if any instances of the script are running by paging down in the script editor's list of active scripts. If there are any instances of the script running, you must find them and stop them. It is impossible to remove a script that is currently running.)
2.Go into the script editor and delete the scripts you wish to remove, by selecting the script and clicking on the DEL key.
3.Go back into the game menu and resave the game, and then quit the game.
4.Go into the game directory and make sure there are no 44****.xml files pointing to the scripts you deleted (these are in the /t directory) If so remove the file. You should know if you installed one of these files into the /t directory when you installed the script. Also check the /scripts directory to make sure the scripts are gone. If not, delete them from the /scripts folder.
5.Open the game and load the save game you saved earlier and the script should be gone.
IF you have the deadly loop script that you had to active manually try this first.
1.Open the save game of the script you wish to remove and go into the script editor.
2.Select the looping script and hit enter on the keyboard to get into the script.
3.Delete any loop commands in the file and at the bottom of the script type break
example;
break
return null
now save the script file then resave the game and then quit the game.
None do steps 1-5 at the top. If this does not work then you’ll have to restart a new game or a old save game.
-----------------------


That's all for now.
Will be back later.
Post specific questions to get answers.
If I'm in error anywhere, please correct me.
Did I mention this was a work in progress?
Last edited by Burianek on Sat, 26. Feb 05, 21:44, edited 2 times in total.
"Nature's first green is gold" . . . stay golden.

broadribb
Posts: 2
Joined: Fri, 12. Dec 03, 00:06
x2

Post by broadribb » Wed, 5. Jan 05, 08:22

I keep reading tutorials and "how to's" about installing mods and scripts. Nothing works . I am now going to tap dance all over my computer. I hate these infernal pieces of crap. Can somebody come up with a simple solution....Not something that requires a Phd in I.T. Please excuse my heated tone, I'm nursing some bleeding Knuckles.
Computationally Challenged

User avatar
Burianek
Posts: 2981
Joined: Mon, 29. Dec 03, 03:29
x3tc

Post by Burianek » Wed, 5. Jan 05, 20:24

Signed scripts are relatively painless to install with the all-in-one bonus pack installer. (sticky thread at top of forum)

For the rest, these tutorials have tried to be written as clearly as possible. If you have specific questions, we'll try to answer them.
"Nature's first green is gold" . . . stay golden.

ryanmylin
Posts: 4
Joined: Thu, 23. Mar 06, 19:36
x3

Post by ryanmylin » Mon, 10. Apr 06, 03:21

i'm trying to get a handle on moding, thought id start out with my personal fav, boron dolphin. wanted 3 125 mw shields, cargo entension to 100000 units, and ability to carry station containers. doesnt sound like much to me, but acording to this thread and the other unpacking repacking thread by burianek, i thought id have my dream ts, but nooo. i think i went verbatem, do i need to change the ship type, or maybe an I.D.? and i do now, have most all the tools to acomplish this. 3dsmax8, its a trial for now, x2tools, x2build, x2editor... any thoughts?


do i need to write a script in order to "activate", i was more fond of changing my new mod files to 05, in succseeion to 04 cat/dat. i really like that ship!

Rolando_D
Posts: 5
Joined: Fri, 15. Jul 11, 10:26

Post by Rolando_D » Fri, 15. Jul 11, 10:59

Hey, Im reallly trying hard to lean how to script, and just get a hold on installing them correctly. Im currently using X3: Terren Conflict, but all the forums told me to refer to this one, and I hope this is still Monitored, but my question basicly is, After extracting script to X3TC directory, I proceed to copy the script folder and past it into original script folder, whereass Im prompted with the question to merge? I am running Vista, and im asked if I want to merge the files, or if I want to replace the original script folder, or skip action. This question is prompted due to same folder name. Am I just missing really stupid, or is the goal to merge?

User avatar
X2-Illuminatus
Moderator (Deutsch)
Moderator (Deutsch)
Posts: 24965
Joined: Sun, 2. Apr 06, 16:38
x4

Post by X2-Illuminatus » Fri, 15. Jul 11, 13:41

Please don't resurrect 5 years old threads. Problems and questions about a specific game are almost always better placed in their respective scripts and modding forum. As you reposted your question in the X3:TC forum, I'm closing this one.


***closed***
Nun verfügbar! X3: Farnham's Legacy - Ein neues Kapitel für einen alten Favoriten

Die komplette X-Roman-Reihe jetzt als Kindle E-Books! (Farnhams Legende, Nopileos, X3: Yoshiko, X3: Hüter der Tore, X3: Wächter der Erde)

Neuauflage der fünf X-Romane als Taschenbuch

The official X-novels Farnham's Legend, Nopileos, X3: Yoshiko as Kindle e-books!

Locked

Return to “X²: The Threat - Scripts and Modding”