Vhati / Slipstream-Mod-Manager

Slipstream allows users to easily install mods for the game FTL: Faster Than Light.
GNU General Public License v2.0
71 stars 16 forks source link

Searching for negatives #7

Open puppetsquid opened 9 years ago

puppetsquid commented 9 years ago

I don't know if you're still updating this, but the Advanced XML could benefit from being able to search for tags based on attributes or children they do not have.

Personally I would most appreciate a findWithoutChildLike tag. e.g. <mod:findWithoutChildLike type="abc" child-type="xyz"> (searches for 'abc' tags that do not contain an 'xyz' child)

Alternatively, adding NOT/NOR/NAND to findComposites' tag may be more useful, if not as elegant. e.g.

<mod:findComposite>
    <mod:par op="AND">
          <mod:findLike type="abc">
          <mod:par op="NOT">
               <mod:findWithChildLike type="abc" child-type="xyz">
          </mod:par>
      </mod:par>
</mod:findComposite>

(searches for 'abc' tags and searches for tags which are not 'abc' with the child 'xyz' - outputs only 'abc' tags without the child 'xyz')

kartoFlane commented 9 years ago

Came up with a rough potential implementation for this: https://github.com/kartoFlane/Slipstream-Mod-Manager/commit/a55226c2e30806457036108d784bb72a79896b9a It's functional, but kinda unwieldy and far from the perfect solution. The message in the linked commit goes into more detail on this.

Examples:

  1. Find all tags other than
<mod:findComposite>
  <mod:par op="AND">
    <mod:findLike />                  <!-- first, match all top-level tags... -->
    <mod-not:findLike type="img" />   <!-- ...next, remove all <img> tags -->
  </mod:par>

  ...
</mod:findComposite>
  1. Find all shipBlueprints without
<mod:findComposite>
  <mod:par op="AND">
    <mod:findLike type="shipBlueprint" />
    <mod-not:findWithChildLike child-type="droneList" />
  </mod:par>

  ...
</mod:findComposite>
  1. Find all weaponBlueprints with value other than LASER
<mod:findComposite>
  <mod:par op="AND">
    <mod:findLike type="weaponBlueprint" />
    <mod-not:findWithChildLike child-type="type">
      <mod:selector>LASER</mod:selector>
    </mod-not:findWithChildLike>
  </mod:par>

  ...
</mod:findComposite>