Before I start id like to say there are a lot of scripters out there that know far more than I do on this subject. So if your one of them feel free to but in and post your own stuff or correct mine. As this thread is aimed at Noobs, all i ask is you keep it Noob friendly.
The entire 440003.xml stuff can be confusing when you first encounter it but after using it you will realise its actually pretty easy stuff.

Scripts as tools
Sometimes its best to write a script to do a job to allow you to test your work without playing an entire game, just to see if it works or not. The scripts need not be complex, in fact sometimes they can be straight forward scripts. So not to confuse you im not going to post anything complex here. Everything starts small so thats where im starting. If you want complex i'll show you my mission scripts sometime... ARGH!

I should warn you, im learning as i go my self so please do not expect me to know all the answers to all the questions at the moment.
Scripts generally.
Every script has something like the following header. Whilst this is important the lines containing the numbers are the real code that actually do the job. However, trying running a script without a header and see how far you get

Code: Select all
Script setneutral.script
Version: 0
for Script Engine Version: 24
Description
Sets the target to be neutral to the player.
Arguments
Source Text
Most scripts are made using a simple choose your command line, add the variables in the correct order system.
So if you had a command that basically say "Is the player in argon prime" then the command may look like this "Is the VAR in SECTOR". You just choose the meaning of the VAR and the name of the SECTOR.
Easy stuff isnt it.

I should warn you that recently Egosoft have stated that choosing a sector object in a script, whilst allowed, may result in your script not saving to your scripts folder. The reason is that your script may be used in a mod that does not have the object you listed in its universe. So a series of "check if exists" type commands may be needed first before you can save your script.
If it does save you will see it in your script folder, best check before quiting the script editor. Im not entirely sure of the best way to check and avoid this but ive seen a lot of commands that do that job so there will be a way.
A couple of my own tools
Here is a few scripts i wrote that allows me to test my mod in the game without worrying about playing the game to the point where a script will work, eg when rank requirements click in or when the test subject is your enemy. My advice is not to save your game after running this scripts. I use them purely as tools when testing other scripts and the galaxy editor.
Setting an object to neutral.
This script simply requires the player to run it, choose a target and press return. That target ship or factory will then be set to neutral to the player allowing you dock or do other things that you possibily could not do before. It does not really work in the Galaxy editor as everything is dockable there but it is useful in the game to stop you from being attacked when testing stuff. I use it primarily when working in my modified pirate sector, i run this script on the defenders so they dont attack me whilst im testing other scripts.
Im learning this X2 scripting lark my self so there may be reasons for not doing things the way I do them in my test scripts that I do not know about. However im posting these to show you how useful a few tool scripts can be when making a mod and giving you the reasons why i wrote them and use them to make point clear. They are also very good practice scripts

Code: Select all
Script setneutral.script
Version: 0
for Script Engine Version: 24
Description
Sets the target to be neutral to the player.
Arguments
Source Text
001 [THIS] -> set relation against [PLAYERSHIP] to Friend
002 return null
Add credits script
Another script thats a real cheat script but sometimes required when you want to test out something you added to a factory but your credits are not enough to buy it is this one.
It gives you enough credits to buy anything you need to test.
Code: Select all
Script init.addcredits
Version: 1
for Script Engine Version: 24
Description
Adds Credits to the players account
Arguments
Source Text
001 add money to player: 1000000000
002 return null
Load your object names script
Code: Select all
Script mynames
Version: 1
for Script Engine Version: 24
Description
loads my names from my 440445.xml file in t folder. 440445 is a file i created btw. my file is 440444.xml. Please avoid using that name:)
Arguments
Source Text
001 load text: id=445
002 return null

(This is actually my init script for HU but ive removed all the Hu lines so not to confuse you if im have not confused you already lol, as soon as this script is loaded the names for my sector objects get loaded too.)
The 440445.xml file must exist before X2 is loaded. Once in the Galaxy editor you need only select the station you want and add an id that points to entry in your 440445 file
Your 440XXX.xml from the T directory.
44 means its an english xml, 0XXX are the id of the script. So if your German, just replace the 44 with the german code which i believe is 49. If you want to support german players too, just make a copy of your script and rename it to 490XXX.xml and drop it in the T folder. It would help if you got somebody to translate the your names and text into german too.

No further changes need be made to support other languages so why not support them ?
Now theres pinned post in this forum already explaining these files far better than i can, so have a read of that.
You will find it at this link.
http://www.egosoft.com/x2/forum/viewtopic.php?t=22519
It can be a little technical but it explains this file in a lot more detail than i am doing.
For now I'll post an example that ive been using that works for me. Im figuring this out as i go along so there may be some errors. However this works and the bottom part containing the author bits works too when writen to the log of the player using one of the log commands that accepts the text id as an arguement. BTW Author lines below simply puts the name between the author tags at the top of the message you send to the players log.
Code: Select all
<?xml version="1.0" encoding="UTF-8" ?>
<language id="44">
<page id="17" title="Boardcomp. objects" descr="Quad line groups for ware factory pairs or twins (spoken by Boardcomputer)">
<t id="6000">Pirate Equipement Dock</t>
<t id="6001">Pirate Shipyard</t>
<t id="6002">Pirate Wharf</t>
<t id="6003">The Big Ban Burger bar (Joke ok)</t>
</page>
<page id="121" title="Mission text" descr="Hostile Universe Missions">
<t id="7000">[author]Nemesis Captain[/author]Paranid Nemesis calling any pilot in Range. We are in need of assistance. Navigation is down, all systems failing. We are caught in some kind of Temporal Storm and are unable to find our way out. The ship has taken heavy damage. Please Assist</t>
<t id="7001">[author]Nemesis Captain[/author]Pilot of approaching Vessel, please lead us out of this storm, we are unable to Navigate. If you guide us to Paranid Prime you will be rewarded.</t>
<t id="7002">[author]Nemesis Captain[/author]The Paranid Navy thanks you Pilot. We are greatful for your timely assistance. Please accept this reward of 250,000 credits for your efforts and the best wishes of our Duke.</t>
<t id="7003">[author]Nemesis Captain[/author]Systems failed... Ships Engines going Critical.....ARGH!!!!!....STATIC...communication has been lost.</t>
<t id="7004">[author]Dan[/author]Hello Julian, Dan here. The Paranid Authorities sent us a report about the Nemesis you encountered. Appearantly it's on board computer stated it had been lost for only day but the Paranid Authorities have been looking for it for weeks. Looks like you solved one mystery and created another. Well done Julian. </t>
</page>
</language>
Code: Select all
<t id="7000">[author]Name of person sending the message[/author]Your message goes here.</t>
If anybody spots any problems with my scripts here please let me know. I only use the top scripts for testing stuff but it would still be nice to get them right

Giskard