[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

Realspace
Posts: 555
Joined: Wed, 15. Nov 06, 11:21
xr

Post by Realspace » Thu, 9. Oct 14, 01:23

is there any galaxy editor on the way? :wink:

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

Post by UniTrader » Thu, 9. Oct 14, 01:30

if you ask because you think i used some kind of tool fot that Map: nope, i am a masochistic raw XML Editor. i think Westbeam started something in that direction, but except simple viewing nothing is included there yet afaik.
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
nidaren
Posts: 66
Joined: Wed, 27. Nov 13, 15:33
x4

Post by nidaren » Mon, 20. Oct 14, 09:15

Hey,

I have a question to the new 2.50 game build.

Is it possible to update specific ship components via script?

For example: Make it find all Scaldis ships existing within player's game and upgrade their cargo component with different one.

Thanks!

User avatar
Litauen
Posts: 191
Joined: Fri, 22. Nov 13, 22:09
xr

Post by Litauen » Mon, 20. Oct 14, 10:21

Check this file: libraries/patchactions.xml

I was unable to make it work for me. If you will succeed - please let me know.

User avatar
wysiwyg
Posts: 584
Joined: Thu, 26. Feb 04, 01:08
x4

Post by wysiwyg » Wed, 22. Oct 14, 21:44

nidaren wrote:Hey,

I have a question to the new 2.50 game build.

Is it possible to update specific ship components via script?

For example: Make it find all Scaldis ships existing within player's game and upgrade their cargo component with different one.

Thanks!
Changing components in-game looks a little tricky :-
Has anyone looked at how the player ship handles its upgrades. In the properties section of the skunk's macro there is a list of upgrades referenced by macro and tagged to the installed component e.g. tags="engine" etc.

e.g.

Code: Select all

In /assets/units/player/macros/unit_player_ship_macro.xml we see:

<macros>
   <macro>
       <properties>
           <upgrades multimacro="1">
                 .......
                 <upgrade upgrade="engine_player_man_mk2_macro" tags="engine" />
                 <upgrade upgrade="engine_player_man_mk3_macro" tags="engine" />
                 <upgrade upgrade="engine_player_man_mk4_macro" tags="engine" />
                 <upgrade upgrade="engine_player_man_mk5_macro" tags="engine" />
                  .........
              </upgrades>
           </....etc
There are scripting commands then to upgrade the ship but I'm not quite sure how they work as they require a percentage value as well as a tag or macro name/value. The upgrades for the skunk are actually handled through the upgrade trader's menu Lua script. Either way the same principle may be able to be applied to cap ships or other assets.

Code: Select all

From /libraries/common.xsd :
      <xs:element name="upgrade_object_by_macro">
        <xs:annotation>
          <xs:documentation>
            Upgrade an object by using a macro and percentage ($object.hasmultimacroupgrades must be true)
          </xs:documentation>
        </xs:annotation>
        <xs:complexType>
          <xs:attributeGroup ref="action" />
          <xs:attribute name="object" type="object" use="required" />
          <xs:attribute name="macro" type="macro" use="required" />
          <xs:attributeGroup ref="range" />
        </xs:complexType>
      </xs:element>

      <xs:element name="upgrade_object_by_tag">
        <xs:annotation>
          <xs:documentation>
            Upgrade an object by using a tag and percentage ($object.hasmultimacroupgrades must be false)
          </xs:documentation>
        </xs:annotation>
        <xs:complexType>
          <xs:attributeGroup ref="action" />
          <xs:attribute name="object" type="object" use="required" />
          <xs:attribute name="tag" type="expression" use="required">
            <xs:annotation>
              <xs:documentation>
                Upgrade tag
              </xs:documentation>
            </xs:annotation>
          </xs:attribute>
          <xs:attributeGroup ref="range" />
        </xs:complexType>
      </xs:element>
I'll dig a bit more when I get time and see what I can come up with.

P.S. I think the patchactions stuff in the library only deals with patches to MD and AI scripts and not component macros - I could well be wrong though as I'm very new to the XML stuff - feel much more comfortable in the Lua script.

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

Post by UniTrader » Wed, 22. Oct 14, 22:25

libraries/patchactions.xml is the right file to look at ;) but no idea how to apply it to Mods.. my best guess is a <action id="modID" version="latestmodversion" > but i would bet this is wrong


@wysiwyg
it doesnt just look tricky.. i used that Method in my Logo Mod, and it is A)weird to use and B) messes up the 0-100% Upgrade System, but basically works fine ;) i have plans on making more use of this (Ship Names on Hull by stacking these Upgrades; Configurable Loadouts for Capships and the Stuff where it gets really weird: real Kit-Ships which can be configured with Modules as needed - but especiallly the last one is far off in the future)

NOTE: upgrade object by macro works in Vanilla only on the Playership, all other Ships use Tag Upgrades (0-100%-upgrades) - and they exclude each other - i would recommend to look into the other approach first since its probably far easier
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
nidaren
Posts: 66
Joined: Wed, 27. Nov 13, 15:33
x4

Post by nidaren » Fri, 24. Oct 14, 08:47

Thanks for the suggestions.

I will look into upgrade_object_by_tag solution. Unable to find any working examples of this method in game, however.

My main aim is to find a method to update the exisiting ships, spawned before the mod has been applied, without the need to manually edit the savegame.

Sadly, by trying the above method, I can't get them to work.

I was trying to also locate the examples of

upgrade_object_by_tag within the game

but faild. Update_object_by_macro indeed only works on Skunk.

EDIT:

I asked CBJ about the issue and he was kind enough to answer:

Hi

Unfortunately patching of existing objects to replace components is something we still have to do in code at the moment. Even if we did expose that to the script system, you'd still have to take care of things like ensuring that cargo was maintained, as this wouldn't happen automatically.


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

Post by UniTrader » Fri, 24. Oct 14, 11:40

in that case i have another method: xmldiff files with msel support ;) i have a program which can apply a diff file to a savegame and a script which applies this to all savegames.. basically it is applying your changes to the ship files to the savegame, too ;)
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 ;)

bm01
Posts: 421
Joined: Wed, 22. Jul 09, 22:31
x4

Post by bm01 » Fri, 24. Oct 14, 12:12

I REQUIRE YOUR ASSISTANCE.
It appears that my mod can't be uninstalled because it adds blocking actions in many scripts. Game crashes on loading and logs show many messages like this one:

Code: Select all

[=ERROR=] Error on AI director import: Invalid blocking action index 9 for context trade.ship on entity 0xc419
How can I make my mod uninstallable?

I have two ideas:

First one: I thought of adding a button to the menu to initiate an uninstallation. First, global variable would be removed. Then, the presence of those variables would be checked in each script, if they are missing I would either destroy the ship (or move.die) if it's a job ship or remove the command if it's a player owned ship. Finally, I need to find a way to prevent job ship from spawning, and I don't know how to do that. But if the check is done soon enough in the script I suspect I wouldn't have to remove all ships, might be wrong though. Also there's a downside, the user would have to wait a few minutes before saving and leaving the game.

Second one: Same menu, same button, but instead of checking variable in scripts, I would directly remove ships and prevent them from spawning again (and cancel commands on player owned ships) in a md cue. But I have no idea if this is doable.

Thoughts?

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

Post by UniTrader » Fri, 24. Oct 14, 13:28

third: provide an uninstall mod which catches all blocking actions, put a goto to the begin of the Script and from there put the script in a state which could be possible in Vanilla (eg copy the part until the first blocking action into your script, set this blocking action to wait for infinity/very long

your regular mod then needs to have the save attribute set to true, the uninstall mod to false - and they both use the same mod id. to uninstall the mod load the game with the uninstall mod, play a few minutes and save again, then load without mod ;)

(just the rough outline how i would do it)
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
nidaren
Posts: 66
Joined: Wed, 27. Nov 13, 15:33
x4

Post by nidaren » Fri, 24. Oct 14, 18:30

Another update:

Update from CBJ about patching existing ships components via script. Good News :)

One more update. Following your request I had a chat with the scripting guy, and in 3.0 we should hopefully be adding script support for you to call the patching function to apply macro changes to existing ships and stations directly.

User avatar
-Skipp-
Posts: 84
Joined: Tue, 7. Oct 14, 10:18
x4

Post by -Skipp- » Tue, 11. Nov 14, 01:08

I'm trying to figure this out... I need to switch some ads ingame for my own ads... I took a look at the initial topic but the asset zip is not available.

Is there anyone that can send me the files that I need to switch for this to work?

Like I said - i just need to replace the adds. Also - can you edit which ad exactly is going to be replaced or is it just random?

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

Post by UniTrader » Tue, 11. Nov 14, 02:20

highway ads or stationn ads?


in the latter case: easily posible if you found the right one. do you want to place new ads there or just want to swap one existing ad for another?
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
-Skipp-
Posts: 84
Joined: Tue, 7. Oct 14, 10:18
x4

Post by -Skipp- » Tue, 11. Nov 14, 10:28

I don't mind any or both. Also - whatever is easier. Swapping existing ads is fine by me

Vim Razz
Posts: 1837
Joined: Tue, 2. Nov 10, 03:20
x4

Post by Vim Razz » Tue, 11. Nov 14, 12:21

The asset file actually ended up developing into a full-blown game extension -- http://forum.egosoft.com/viewtopic.php?t=367490

Individual files from the tutorial and such can be extracted with the Rebirth Tools catalog tool.

Post Reply

Return to “X Rebirth - Scripts and Modding”