[TUTORIAL] X Rebirth - Modding Guide

The place to discuss scripting and game modifications for X Rebirth.

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

Exavier724
Posts: 118
Joined: Fri, 12. Dec 03, 02:13
x2

Post by Exavier724 » Tue, 30. Dec 14, 16:19

Observe wrote:
Exavier724 wrote:Quick question... Does anyone have the "5. Example mod extension developed for this guide (download here)" that was created for the guide in the original post?

Seems i get a file not found error like it has been deleted from nexusmods
The "Example Mod" is available on Steam in two different versions: "Transcend - With Highways" and "Transcend - No Highways". The mod has evolved since this tutorial was written, but all the same code references (and more) still exist. The forum discussion thread is here and the Steam download is here.

Thanks.
Thanks :)
Decided to see if i could sit down and make a single sector playground system for empire building. Just a gate to each cluster, a couple of NPC stations, guard fleets for the gate areas (depending on where the gate leads), and alot of player build space.

So far the thing is functional except for Quotas, Jobs, & Gate Locks (if used during the campaign). :P

EDIT: This is trickier than I thought it was going to be... Though just a cpl tweaks to my highways and I think I got it working. Gates even open properly based on campaign progression :)

Wonder if I should put it up on workshop for ppl who want a crossroads empire building area. Especially now that we have galaxy trader mods.

Still can't seem to get a background other than Albion though. even when I changed all the fields I could find for it.

Sanyokbig
Posts: 31
Joined: Fri, 6. Apr 12, 13:01
x4

Post by Sanyokbig » Thu, 1. Jan 15, 22:19

Hi. Is there any list of all commands describing what they do and what parameters have?

UniTrader
Moderator (Script&Mod)
Moderator (Script&Mod)
Posts: 14571
Joined: Sun, 20. Nov 05, 22:45
x4

Post by UniTrader » Thu, 1. Jan 15, 22:22

what commands you you mean? aiscripts? md? Ingame-commandline?
if not stated otherwise everything i post is licensed under WTFPL

Ich mache keine S&M-Auftragsarbeiten, aber wenn es fragen gibt wie man etwas umsetzen kann helfe ich gerne weiter ;)

I wont do Script&Mod Request work, but if there are questions how to do something i will GLaDly help ;)

Sanyokbig
Posts: 31
Joined: Fri, 6. Apr 12, 13:01
x4

Post by Sanyokbig » Thu, 1. Jan 15, 23:15

XML ones. Trying to work with aiscripts. But without command reference like in Arma for example it's kinda hard

UniTrader
Moderator (Script&Mod)
Moderator (Script&Mod)
Posts: 14571
Joined: Sun, 20. Nov 05, 22:45
x4

Post by UniTrader » Thu, 1. Jan 15, 23:23

libraries/aiscripts.xsd and libraries/common.xsd provide all available Commands (best to use them with an autocompleting xml editor like xmlcopyedit; just extract both files and link the aiscripts.xsd like its done in all other script files and autocomplete should work), and if you have trouble with the expressions look into the scriptproperties.html ;)
if not stated otherwise everything i post is licensed under WTFPL

Ich mache keine S&M-Auftragsarbeiten, aber wenn es fragen gibt wie man etwas umsetzen kann helfe ich gerne weiter ;)

I wont do Script&Mod Request work, but if there are questions how to do something i will GLaDly help ;)

Sanyokbig
Posts: 31
Joined: Fri, 6. Apr 12, 13:01
x4

Post by Sanyokbig » Thu, 1. Jan 15, 23:57

Thanks, it became a little clearer now

can .xsd files be opened so i can see documentation in formatted view without .xml tags?

About linking, never done it. Should i place them in one folder and define .xsd in header via xsi:noNamespaceSchemaLocation="aiscripts.xsd" or it's fine if .xsd is in one folder and .xml in another like in game catalogs?

And for the scriptproperties.html, where can i find it? :)

UniTrader
Moderator (Script&Mod)
Moderator (Script&Mod)
Posts: 14571
Joined: Sun, 20. Nov 05, 22:45
x4

Post by UniTrader » Fri, 2. Jan 15, 00:51

not sure if there is some xsl file which formats this Info nicely, but i think this may be useful:
http://stackoverflow.com/a/2176503

scriptproperties.html is in the root directory when you extracted your files, but requires some files in the libraries folder to work properly - i would recommend extracting all Game files in a sub-directroy of the Game folder to allow easy access to all files, i have written a short script for that a while ago:

Code: Select all

mkdir "..\X Rebirth\XR_extracted"
XRcatTool.exe -in "..\X Rebirth\01.cat" "..\X Rebirth\02.cat" "..\X Rebirth\03.cat" "..\X Rebirth\04.cat" "..\X Rebirth\05.cat" "..\X Rebirth\06.cat" "..\X Rebirth\07.cat" "..\X Rebirth\08.cat" "..\X Rebirth\09.cat" -out "..\X Rebirth\XR_extracted"
simply put it right next to the XRCatTool.exe from EGO and let it do its magic™ ^^
if not stated otherwise everything i post is licensed under WTFPL

Ich mache keine S&M-Auftragsarbeiten, aber wenn es fragen gibt wie man etwas umsetzen kann helfe ich gerne weiter ;)

I wont do Script&Mod Request work, but if there are questions how to do something i will GLaDly help ;)

Exavier724
Posts: 118
Joined: Fri, 12. Dec 03, 02:13
x2

Post by Exavier724 » Fri, 2. Jan 15, 09:39

Is there a way trigger an auto explore on a sector? So that when the game start it reveals the zones, highways, and static objects (stations) as if you had flown there.

Trying to get zones & highways to line up but its a pain having to start a new game (gates don't seem to move otherwise) and fly around discovering everything every time.

UniTrader
Moderator (Script&Mod)
Moderator (Script&Mod)
Posts: 14571
Joined: Sun, 20. Nov 05, 22:45
x4

Post by UniTrader » Fri, 2. Jan 15, 14:22

<set_known/> for any object you might be interested. just use some <find_.../> commands vague enough to returnn all shipe/zones/sectors/stations and then <do_all/>
if not stated otherwise everything i post is licensed under WTFPL

Ich mache keine S&M-Auftragsarbeiten, aber wenn es fragen gibt wie man etwas umsetzen kann helfe ich gerne weiter ;)

I wont do Script&Mod Request work, but if there are questions how to do something i will GLaDly help ;)

UniTrader
Moderator (Script&Mod)
Moderator (Script&Mod)
Posts: 14571
Joined: Sun, 20. Nov 05, 22:45
x4

Post by UniTrader » Wed, 7. Jan 15, 02:07

i think its something like
[ 'shieldgenerator' , 100 , 'turret_small_mg' , 100 , 'turret_medium_pe' , 100 ]
similiar to the buildplanlist (numbers here probably define the percentage of installed upgrades since thats how its done with the Upgrade Commands )

if you want to be sure modify the NPC_Architect.xml with

Code: Select all

<add sel="//do_elseif[@value="event.param == &apos;cArch_buildermacrosResult&apos;"]" pos="prepend">
<debug_text text="event.param2.{3}" filter="general" />
</add>
and order some stations with upgrades - expected Format for this list should then appear in the debuglog
if not stated otherwise everything i post is licensed under WTFPL

Ich mache keine S&M-Auftragsarbeiten, aber wenn es fragen gibt wie man etwas umsetzen kann helfe ich gerne weiter ;)

I wont do Script&Mod Request work, but if there are questions how to do something i will GLaDly help ;)

Exavier724
Posts: 118
Joined: Fri, 12. Dec 03, 02:13
x2

Post by Exavier724 » Wed, 7. Jan 15, 14:58

lol thanks. I actually realized about an hour after I posted, which is why i deleted my comment, that the station did have guns on it. They just don't show up in the stations details screen they start shooting at you. Guess the NPCs don't need to actually buy turrets for their stations. I can live with that :P

Now I just need to finish up my jobs, name my zones/sectors properly (hate naming things lol), and adjust my gate activation script and I think it will be ready for steam :)

Thanks for your help.

Sparky Sparkycorp
Moderator (English)
Moderator (English)
Posts: 8074
Joined: Tue, 30. Mar 04, 12:28
x4

Post by Sparky Sparkycorp » Sun, 22. Mar 15, 20:08

Hi Observe,

The following nexus link is broken on the first page:
5. Example mod extension developed for this guide (download here)
I'd welcome a new one :)

Regards,
Sparks

kMotion
Posts: 19
Joined: Thu, 9. Apr 15, 16:29
xr

Post by kMotion » Sat, 25. Apr 15, 23:49

Hello every one, I'm new in modding for X Rebirth. Who can say, where I can find tutorials? Where I can find info about global variables, function, arrays, etc in x rebirth? How can I start in modding? Thanks!

UniTrader
Moderator (Script&Mod)
Moderator (Script&Mod)
Posts: 14571
Joined: Sun, 20. Nov 05, 22:45
x4

Post by UniTrader » Sun, 26. Apr 15, 00:11

what kind of Mod do you have in mind? this tuto is primarily for Universe Editing, but there are other kinds of mods, too.. and regarding Script commands: see the previous Posts about aiscript and md - and also the part about extracting the Game files
if not stated otherwise everything i post is licensed under WTFPL

Ich mache keine S&M-Auftragsarbeiten, aber wenn es fragen gibt wie man etwas umsetzen kann helfe ich gerne weiter ;)

I wont do Script&Mod Request work, but if there are questions how to do something i will GLaDly help ;)

User avatar
wysiwyg
Posts: 585
Joined: Thu, 26. Feb 04, 00:08
x4

Post by wysiwyg » Sun, 26. Apr 15, 00:13

kMotion wrote:Hello every one, I'm new in modding for X Rebirth. Who can say, where I can find tutorials? Where I can find info about global variables, function, arrays, etc in x rebirth? How can I start in modding? Thanks!
Well, this tutorial by observe is a very good starting point. Also the posts stickied at the top of the board have some very good information about such things as publishing to steam, in-game tools, a PDF guide to the Mission Director (MD), etc.

I found studying other people's work was the best way to actually start understanding how it all fits together because you can see the results of the code in-game just by installing the mod.

As far as tools go all you need is a good XML editor such as MS Visual Studio Express (free) and something like notepad++ or Programmer's Notepad if you want to edit Lua files (you could use just either one of those editors but I find VS better for XML as it has tooltip documentation and schema checking built in, NP++ is just a better all round editor for general text based coding such as Lua script IMO)

Once you have an idea what you want to do you should unpack the game's cat/dat files and you'll find that most of the reference documentation is contained within these unpacked files in the form of XML schema files (*.xsd). There is also a very useful file called scriptproperties.html that you can load in a browser that is a useful reference.

If you want to mod the UI then you'll need some knowledge of Lua scripting and, again, study the game's files and use the links in the UI modding sticky as a further guide (The sticky also points to Egosoft's own confluence page with a ton more info on the UI).

Best single bit of advice: Study other modders' work!

Good luck
Wysi :)

kMotion
Posts: 19
Joined: Thu, 9. Apr 15, 16:29
xr

Post by kMotion » Sun, 26. Apr 15, 11:27

Thanks for all, interesting XML modding. How can I create an array? How can I found a random field from array? How can I save a variable param in string, how can I use that string parameters? Where I can read about all of this? Maybe you know useful posts on this forum or another sites?

User avatar
wysiwyg
Posts: 585
Joined: Thu, 26. Feb 04, 00:08
x4

Post by wysiwyg » Sun, 26. Apr 15, 12:21

kMotion wrote:Thanks for all, interesting XML modding. How can I create an array? How can I found a random field from array? How can I save a variable param in string, how can I use that string parameters? Where I can read about all of this? Maybe you know useful posts on this forum or another sites?
There is a sticky above called [Index] X Rebirth Tools, Tutorials and Resources The Mission Director Guide by Egosoft is a very good starting point to understand syntax and semantics of the modding language.

The documentation for the game is here and inside the game files themselves. Arrays are called lists in XR modding, you also have hashed lists called tables that are used in both MD/AI scripting and Lua (User Interface, UI) scripting.

Study other modders' work! The game has only been around for a year and a bit so there is no easy casual formula for modding it. You must study what is there and understand it if you want to write mods.

Wysi :)

insaneno
Posts: 2
Joined: Mon, 17. Nov 14, 19:16

Post by insaneno » Tue, 20. Oct 15, 16:39

I was just curious, how do i add ships to build list? i want to add reaver fighters to build list but cant find anywhere how to do it?

UniTrader
Moderator (Script&Mod)
Moderator (Script&Mod)
Posts: 14571
Joined: Sun, 20. Nov 05, 22:45
x4

Post by UniTrader » Tue, 20. Oct 15, 18:04

look into the Production Modules of the respective Stations for small ships, you can find them in
assets\structures\Economy\production\macros
as one of these files:
struct_econ_prod_shipm_macro.xml
struct_econ_prod_shipm_dv_macro.xml
struct_econ_prod_shipm_dv_macro.xml
struct_econ_prod_ships_macro.xml
struct_econ_prod_ships_dv_macro.xml
struct_econ_prod_ships_dv_macro.xml

adding a new Product to the production queue should do the trick:

Code: Select all

<?xml version="1.0" encoding="UTF-8"?>
<diff>
  <replace sel="//production/@wares">shp_m_ore_transporter shp_m_ice_collector shp_m_crystal_collector shp_m_container_transporter shp_m_energy_transporter shp_m_liquid_transporter shp_m_ions_collector shp_m_hydrogen_collector ANDYOURNEWPRODUCT</replace>
  <add sel="//production/queue">
    <item ware="ANDYOURNEWPRODUCT" />
  </add>
</diff>
(put this into a file with the same Name and Path as the Vanilla file you want to change, but inside your Extension, not in the game root)
in the optimum case the add should be enough because it makes adding Ships from multiple mods for production trivial, but i think the first (replace) is also needed..
if not stated otherwise everything i post is licensed under WTFPL

Ich mache keine S&M-Auftragsarbeiten, aber wenn es fragen gibt wie man etwas umsetzen kann helfe ich gerne weiter ;)

I wont do Script&Mod Request work, but if there are questions how to do something i will GLaDly help ;)

insaneno
Posts: 2
Joined: Mon, 17. Nov 14, 19:16

Post by insaneno » Thu, 22. Oct 15, 02:39

I cant seem to get it to work no matter which way I set it up, there just not showing up in the build tree. can you show me how to do it with multiple additions?

Post Reply

Return to “X Rebirth - Scripts and Modding”