Question for master modders

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

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

bradines
Posts: 31
Joined: Fri, 27. Mar 15, 20:58

Question for master modders

Post by bradines »

<xs:element name="patch_macro">
<xs:annotation>
<xs:documentation>
Patch an object based on its macro, to add components that may be missing when loading a savegame. This action is only required by extensions and should normally only be used when loading a savegame
in which the extension was not active yet. The script is responsible for finding the objects, usually ships or stations, that need patching.
</xs:documentation>
</xs:annotation>
<xs:complexType>
<xs:attributeGroup ref="action" />
<xs:attribute name="object" type="object" use="required" />
</xs:complexType>
</xs:element>
i think this function will let me patch existing ships to apply changes to them, but i don't really understand how to call the function from my mod. any help would be nice...
User avatar
Marvin Martian
Posts: 3617
Joined: Sun, 8. Apr 12, 09:40
x4

Post by Marvin Martian »

to patch a single ship by conversation (in that case with the defence guy) make an YourModpatch.xml on the md/ folder

in that example the option will be shown on Sul and heavy Sul, add your macro in the conditionarea for the shiptype you want to patch

Code: Select all

<?xml version="1.0" encoding="utf-8"?>
<mdscript name="YourMod" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="md.xsd">
	<cues>
		<!--  conversation hook defence guy  -->
		<cue name="Base" instantiate="true" >
			<conditions>
				<check_any>
					<event_conversation_started conversation="default" />
					<event_conversation_returned_to_section section="default" />
				</check_any>
				<check_value value="event.object.type" exact="entitytype.defencecontrol" />
				<check_value value="event.object.owner" exact="faction.player" />
				<check_value value="event.object.iscontrolentity" />
				<check_any>
					<check_value value="event.object.container.macro" exact="macro.units_size_l_kit_carrier_01_macro" />
					<check_value value="event.object.container.macro" exact="macro.units_size_l_kit_carrier_02_macro" />
				</check_any>
			</conditions>
			<actions>
				<add_player_choice_sub text="'Yeah, pimp my ride!'" section="ymod_pimpmyride" />
			</actions>
		</cue>
		<cue name="YourMod_patch" instantiate="true">
			<conditions>
				<check_any>
					<event_conversation_next_section section="ymod_pimpmyride"/>
				</check_any>
			</conditions>
			<actions>
				<patch_macro object="event.object.container" />
			</actions>
		</cue>	
	</cues>
</mdscript>
but in case you modify a macro and want to patch all ships in the universe simply use the <patch_macros >
in that Sample below both Sul-types will patched once only after load the game

Code: Select all

<?xml version="1.0" encoding="utf-8"?>
<mdscript name="YourMod" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="md.xsd"> 
   <cues> 
      <cue name="Base" version="1"> 
         <conditions> 
               <event_game_loaded/> 
         </conditions> 
         <actions> 
            <patch_macros macro="macro.units_size_l_kit_carrier_01_macro"/> 
            <patch_macros macro="macro.units_size_l_kit_carrier_02_macro"/> 
         </actions> 
      </cue> 
   </cues> 
</mdscript>
antoniut
Posts: 198
Joined: Sat, 4. Oct 14, 13:07
x4

Post by antoniut »

@Marvin

Oops, I was seeking for this too. But in my case I would like to do it with a station. Sorry I'm very newbie on coding. In the second example the short one, where it says: mdscript name="YourMod" is the name of the folder extension of the mod in question, true?

And I supose in the case of a station where it says: patch_macros macro="macro.units_size_l_kit_carrier_01_macro"/ then here the macro's name of the station, true?

Thanks a lot and sorry for interfere in the thread.
UniTrader
Moderator (Script&Mod)
Moderator (Script&Mod)
Posts: 14571
Joined: Sun, 20. Nov 05, 22:45
x4

Post by UniTrader »

antoniut wrote:Oops, I was seeking for this too. But in my case I would like to do it with a station. Sorry I'm very newbie on coding. In the second example the short one, where it says: mdscript name="YourMod" is the name of the folder extension of the mod in question, true?
this is an individual Name for each MDscript - just keep it the same as the File Name and choose one which wont collide with the Game Files or other Mods ;)
antoniut wrote:And I supose in the case of a station where it says: patch_macros macro="macro.units_size_l_kit_carrier_01_macro"/ then here the macro's name of the station, true?
exactly. it is basically a merged <find_objects/> and <patch_macro/> command ;)
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 ;)
antoniut
Posts: 198
Joined: Sat, 4. Oct 14, 13:07
x4

Post by antoniut »

@Unitrader

I'm near to love you, Unitrader :D (not sex related obviusly, and my english sucks... I know)
User avatar
Marvin Martian
Posts: 3617
Joined: Sun, 8. Apr 12, 09:40
x4

Post by Marvin Martian »

antoniut wrote: then here the macro's name of the station, true?
as much i figured out, that patch_macro(s) doesn't have much effect on stations

you can patch Ships very good, but Stations or especially productions haven't changed yet in my tests after patching them that way

if i'm wrong, let me know :wink:
bradines
Posts: 31
Joined: Fri, 27. Mar 15, 20:58

Post by bradines »

k i got it working and i think i know why you can't patch a station production...

because the patch command just looks for what is missing in a macro from the save file compared to the version that is i nthe system... so if you just try to add a macro that has the same anme at the same point it ignores it..
Phipsz
Posts: 335
Joined: Mon, 23. Apr 12, 23:56
x4

Post by Phipsz »

maybe trying to patch each submacro of a station would help? or is that already covered by the patch_macro(s) ? maybe the patch_macro looks at the "main" macro of the station and sees no difference, because it is changed somewhere beneath in a different macro.

didn't try myself yet, just passing thoughts.
UniTrader
Moderator (Script&Mod)
Moderator (Script&Mod)
Posts: 14571
Joined: Sun, 20. Nov 05, 22:45
x4

Post by UniTrader »

i think its more like removing the changed factory parts (destroy without explosion) and then patching the Station..
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 ;)

Return to “X Rebirth - Scripts and Modding”