[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 » 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?

w.evans
Posts: 2963
Joined: Tue, 18. Nov 14, 16:23
x4

Post by w.evans » Thu, 22. Oct 15, 04:13

Can't remember for certain, but I seem to remember that you'll have to either start a new game or patch existing shipyards in a running game in addition to the changes UniTrader mentioned.

So, for example, to add the Katana to Albion m-ship shipyards, you'll need to add:

Code: Select all

shp_m_canteran_01
to the production queue of

Code: Select all

struct_econ_prod_shipm_macro.xml
like this:

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 shp_m_canteran_01</replace>
  <add sel="//production/queue">
    <item ware="shp_m_canteran_01"/>
  </add>
</diff>
This should be in:

\extensions\YOUR_MOD\assets\structures\Economy\production\macros\struct_econ_prod_shipm_macro.xml

Then, to patch the shipyards for existing saves, something like:

Code: Select all

<?xml version="1.0" encoding="ISO-8859-1" ?>
<mdscript name="Your_Mod_Init">
	<cues>
		<cue name="Your_Mod_Patch_Shipyards">
			<conditions>
				<event_game_loaded />
			</conditions>
			<actions>
				<patch_macros macro="macro.struct_econ_prod_shipm_macro"/>
			</actions>
		</cue>
	</cues>
</mdscript>
in something like:

\extensions\YOUR_MOD\md\your_mod_init.xml

Anubitus
Posts: 693
Joined: Fri, 21. Jan 05, 00:44
x4

Post by Anubitus » Fri, 8. Apr 16, 04:38

hey guys, how can i create custom .ogg sound files for x rebirth..? i tried using Audacity -> exporting as .wav and then converting it to .ogg with FlicFlac audioconverter but the sounds sound distorted and deep/low..

Browser_ice
Posts: 485
Joined: Sun, 5. Feb 06, 17:15
x4

Post by Browser_ice » Sat, 30. Jul 16, 22:03

Started to check out this thread and I am starting to see some dead links.

osr_universe.rar (think anything in read is a dead link)

5. Example mod extension developed for this guide (download here)
http://xrebirth.nexusmods.com/mods/28/? (none existing on Nexus)

Also all images using http://www.worldwidemods.com are dead. Domain no longer existing.

Also, the last update is from 2014 ? Is it even still 100% compatible with XRebirth 4.* ?

Rarely any recent replies done also .....

Most XML examples are based on the RAR file above and are not fully displayed. So without this file, someone cannot really advance.

Is this thread still good enough for someone to start creating a MOD without having to go through all the 16 pages ???
Steam X-Superbox, XR, playing X4
WIndows-10
Intel I7-3770
16Gb Memory
Nvgidia GTX-1060

User avatar
Observe
Posts: 5079
Joined: Fri, 30. Dec 05, 17:47
xr

Post by Observe » Sat, 17. Dec 16, 19:27

Hello. File and image links are now updated. I apologize for not doing a better job of maintaining this thread. My internet access is infrequent and I am unable to answer questions, but hopefully the tutorial will make better sense with the accompanying images etc.

Thanks.

User avatar
Herman2000
Posts: 42
Joined: Sat, 24. Aug 13, 22:20
x4

Re: [TUTORIAL] X Rebirth - Modding Guide

Post by Herman2000 » Sat, 21. Sep 19, 07:48

So, seeing as this excellently-written guide is linked in the stickied thread, it might be prudent (in spite of the thread's age) to point out that the example files are, once again not available, and that no archive page in the universe seems to have them stored, either. =\ Bummer, I'd really like to have a look at some of the stuff.

EDIT: Derp. I guess I can just as well reference from the finalized mod. Still, thought it'd be prudent to point out.

mcsaba
Posts: 1
Joined: Wed, 11. Mar 09, 09:24
x4

Re: [TUTORIAL] X Rebirth - Modding Guide

Post by mcsaba » Tue, 13. Apr 21, 16:53

Hi,

Anybody could update links of images and example mod in the guide?
Or somebody could share the example mod with me?

Thank you :)

danadi712
Posts: 45
Joined: Sun, 1. Feb 15, 19:07

Re: [TUTORIAL] X Rebirth - Modding Guide

Post by danadi712 » Tue, 5. Apr 22, 15:13

Has anyone an ideea on how to change cargo capacity on ships?
I am interested on medium and capital trade ships

User avatar
alexalsp
Posts: 1820
Joined: Fri, 18. Jul 14, 05:28
x4

Re: [TUTORIAL] X Rebirth - Modding Guide

Post by alexalsp » Tue, 5. Apr 22, 19:06

danadi712 wrote:
Tue, 5. Apr 22, 15:13
Has anyone an ideea on how to change cargo capacity on ships?
I am interested on medium and capital trade ships

assets\props\StorageModules\macros\

cargobay_ship_*_container_*_macro

danadi712
Posts: 45
Joined: Sun, 1. Feb 15, 19:07

Re: [TUTORIAL] X Rebirth - Modding Guide

Post by danadi712 » Thu, 7. Apr 22, 21:44

I unpacked 09.cat and i find those macros
I create a folder SHIPS with structure SHIPS\assets\props\StorageModules\macros
in folder macros i change in file cargobay_ship_m_bulk_01_macro.xml
<cargo max="18000" tags="bulk" />
to
<cargo max="600" tags="bulk" />
From my understanding this is for GIGURUM BULK type M class ship
I put folder SHIPS in folder EXTENSIONS
New GAME
Nothing changes
What is the problem?

User avatar
alexalsp
Posts: 1820
Joined: Fri, 18. Jul 14, 05:28
x4

Re: [TUTORIAL] X Rebirth - Modding Guide

Post by alexalsp » Fri, 8. Apr 22, 10:02

Show the file code.

This cargo hold can be used for different ships. You need to open the Gigurum ship file and see what cargo bays are connected to it.

Code: Select all

assets\units\size_*\Macros\

Code: Select all

<?xml version="1.0" encoding="utf-8"?>
<!--Exported by: Michael (192.168.3.145) at 18.07.2014_10-54-03-->
<macros>
  <macro name="units_size_m_weapontech_transporter_macro" class="ship_m" alias="units_size_m_container_transporter_5_macro">
    <component ref="units_size_m_weapontech_transporter" />
    <properties>
      <identification name="{20101,2801}" basename="{20101,2803}" description="{20101,2802}" variation="{20106,2101}" mapicon="shipicon_freighter_m" />
      <hull max="55000" />
      <effects>
        <explosion ref="explosion_m_02" />
      </effects>
      <purpose primary="trade" />
    </properties>
    <connections>
      <connection ref="connection_cockpit01">
        <macro ref="cockpit_bridge_size_m_macro" connection="Connection01" />
      </connection>
      <connection ref="connection_engine01">
        <macro ref="engine_size_s_02_macro" connection="connection_component01" />
      </connection>
      <connection ref="connection_engine02">
        <macro ref="engine_size_s_02_macro" connection="connection_component01" />
      </connection>
      <connection ref="connection_radar01">
        <macro ref="radar_ship_m_freighter_01_macro" connection="ship" />
      </connection>
      <connection ref="connection_shieldgen01">
        <macro ref="shieldgenerator_ship_m_03_macro" connection="Connection01" />
      </connection>
      <connection ref="connection_storage01">
        <macro ref="storage_ship_m_container_01_macro" connection="ShipConnection" />
      </connection>
    </connections>
  </macro>
</macros>

Code: Select all

storage_ship_m_container_01_macro

Code: Select all

<?xml version="1.0" encoding="utf-8"?>
<!--Exported by: Michael (192.168.3.144) at 03.03.2015_16-52-12-->
<macros>
  <macro name="storage_ship_m_container_01_macro" class="storage">
    <component ref="generic_storage" />
    <properties>
      <identification name="{20109,401}" />
      <hull integrated="1" />
    </properties>
    <connections>
      <connection ref="cargo">
        <macro ref="cargobay_ship_m_container_01_macro" connection="StorageConnection" />
      </connection>
    </connections>
  </macro>
</macros>
This is the desired storage.

Code: Select all

cargobay_ship_m_container_01_macro

Code: Select all

<?xml version="1.0" encoding="utf-8"?>
<!--Exported by: Michael (192.168.3.144) at 03.03.2015_16-53-20-->
<macros>
  <macro name="cargobay_ship_m_container_01_macro" class="cargobay">
    <component ref="generic_cargobay" />
    <properties>
      <cargo max="12000" tags="container" />
      <hull integrated="1" />
    </properties>
  </macro>
</macros>

Code: Select all

<?xml version="1.0" encoding="UTF-8" ?> 
<diff>
 <replace sel="//properties/cargo/@max">600</replace> 
</diff>

Post Reply

Return to “X Rebirth - Scripts and Modding”