Help with advanced xml tags

Discuss and distribute tools and methods for modding. Moderator - Grognak
MantisManMike
Posts: 58
Joined: Tue Dec 12, 2017 6:29 pm

Help with advanced xml tags

Postby MantisManMike » Thu Nov 21, 2019 5:10 pm

With Slipstream's advanced XML tags, you can do stuff like this:

Code: Select all

<mod:findName type="shipBlueprint" name="MANTIS_SCOUT">
   (Make some changes to the Mantis Scout blueprint here)
</mod:findName>


Instead of selecting just one blueprint, I'd like to select several, and have the changes applied to all of them. I tried using <mod:findComposite>, but couldn't get it to work. Any ideas?

I could just keep copying & pasting the code, but it's getting pretty long.
User avatar
mr_easy_money
Posts: 615
Joined: Fri May 29, 2015 9:05 pm
Location: A galaxy far, far away

Re: Help with advanced xml tags

Postby mr_easy_money » Sun Nov 24, 2019 11:08 pm

MantisManMike wrote:Instead of selecting just one blueprint, I'd like to select several, and have the changes applied to all of them. I tried using <mod:findComposite>, but couldn't get it to work. Any ideas?

I could just keep copying & pasting the code, but it's getting pretty long.

hopefully I am not too late with this reply,

mod:findComposite format looks like this

Code: Select all

<mod:findComposite>
   <mod:par op="OR">
      <mod:findName type="shipBlueprint" name="MANTIS_SCOUT" />
      <mod:findName type="shipBlueprint" name="REBEL_FAT" />
      <!-- works for any find... tags. note that mod:selector can be placed within find... tags here. -->
   </mod:par>
   <!-- (Make some changes to the Mantis Scout blueprint here) -->
</mod:findComposite>

my "Change all crew to one race" mod does just what you said except to all player ships (viewtopic.php?f=11&t=30267#p107866, there is a code snippet at the top).

you may have been getting confused by the "AND" used in the readme_modders.txt. it's logical AND (Vhati explains an incorrect usage here: viewtopic.php?f=12&t=17102&p=114922#p114932). so in most cases you'll want to use OR logic because you want to make the same changes for multiple different things.

I think a possible usage of AND could be to do the same thing to different ships or weapons that share similar attributes. maybe ships that have a certain threshold of health (6 to 9) and a certain power threshold (6 to 9) should have certain systems buffed:

Code: Select all

<mod:findComposite>
   <mod:par op="AND">
      <mod:par op="OR">
         <mod:findWithChildLike type="shipBlueprint" child-type="health"><mod:selector amount="6" /></mod:findWithChildLike>
         <mod:findWithChildLike type="shipBlueprint" child-type="health"><mod:selector amount="7" /></mod:findWithChildLike>
         <mod:findWithChildLike type="shipBlueprint" child-type="health"><mod:selector amount="8" /></mod:findWithChildLike>
         <mod:findWithChildLike type="shipBlueprint" child-type="health"><mod:selector amount="9" /></mod:findWithChildLike>
      </mod:par>
      <mod:par op="OR">
         <mod:findWithChildLike type="shipBlueprint" child-type="maxPower"><mod:selector amount="6" /></mod:findWithChildLike>
         <mod:findWithChildLike type="shipBlueprint" child-type="maxPower"><mod:selector amount="7" /></mod:findWithChildLike>
         <mod:findWithChildLike type="shipBlueprint" child-type="maxPower"><mod:selector amount="8" /></mod:findWithChildLike>
         <mod:findWithChildLike type="shipBlueprint" child-type="maxPower"><mod:selector amount="9" /></mod:findWithChildLike>
      </mod:par>
   </mod:par>
   <mod:findLike type="systemList">
      <mod:findLike type="shields">
         <mod:setAttributes power="3" />
      </mod:findLike>
      <mod:findLike type="weapons">
         <mod:setAttributes power="3" />
      </mod:findLike>
   </mod:findLike>
</mod:findComposite>

yeah this looks incredibly verbose but I tried to come up with an example with utility. "multiple nested <par > tags" is basically this combination of AND and OR. it would be great if we could get functionality for logical NOT, because then we could form all the other various logical operators. findWithoutChildLike (negate findWithChildLike) would go such a long way imo. anyways, I hope this answered some questions?
MantisManMike
Posts: 58
Joined: Tue Dec 12, 2017 6:29 pm

Re: Help with advanced xml tags

Postby MantisManMike » Thu Nov 28, 2019 11:18 pm

Thanks, that's really helpful! :) Looks like I just didn't understand the expected structure.
MantisManMike
Posts: 58
Joined: Tue Dec 12, 2017 6:29 pm

Re: Help with advanced xml tags

Postby MantisManMike » Mon Dec 02, 2019 12:27 pm

Just a quick update to say that it worked, thanks!

Who is online

Users browsing this forum: No registered users and 12 guests