Skip to content

getplants: add dry-run and trait filter options - #5949

Open
Alistair-Afton wants to merge 1 commit into
DFHack:developfrom
Alistair-Afton:getplants-filters
Open

Alistair-Afton wants to merge 1 commit into
DFHack:developfrom
Alistair-Afton:getplants-filters

Conversation

@Alistair-Afton

Copy link
Copy Markdown
Contributor

Implements both parts of #5768:

Dry run: -d/--dry-run reports how many plant designations would be set or cleared without changing anything, using Designations::canMarkPlant/canUnmarkPlant so the count is exactly what a real run would produce (all existing ripeness/already-picked/already-designated checks still apply).

Trait filters: --brewable, --edible, --oil, --cloth, and --dye restrict the selection to plants with the requested uses. They compose with -a, explicit IDs, -x (invert stays within the filtered pool), -t/-s, -f, and -c, and they also restrict the valid-ID listing (getplants --brewable lists brewable species).

Trait detection uses the same criteria as the vanilla reactions:

  • --brewable: DRINK_MAT reaction product on the structural material or any growth material (as required by BREW_DRINK_FROM_PLANT/_GROWTH)
  • --oil: PRESS_LIQUID_MAT reaction product on the seed material (milled to paste) or growth materials (pressed directly)
  • --edible: EDIBLE_RAW on the structural material or any growth material
  • --cloth: the THREAD plant flag
  • --dye: IS_DYE on mill/extract material defs or growth materials

Verified in-game on 53.16: --brewable lists exactly the vanilla brewables (wheats, berries, rat weed, etc.), --cloth the thread plants, --dye the four dye plants (dimple cup, blade weed, hide root, sliver barb), and --oil the pressable species (flax/hemp/cotton/kenaf seeds, olive, quarry bush). Dry-run reports match real runs exactly.

New in-engine regression test test/plugins/getplants.lua covers dry-run/real-run parity, designation round-tripping, trait filter acceptance/rejection, and listing correctness. 3/3 tests, 98/98 checks pass.

Closes #5768

Adds --dry-run (-d) to report how many plant designations would be
set or cleared without changing anything, and --brewable/--edible/
--oil/--cloth/--dye trait filters that restrict the selection (and the
ID listing) to plants with the requested uses. Trait filters compose
with -a, explicit IDs, -x, -t/-s, -f, and -c.

Brewable and oil-bearing plants are identified by the material reaction
products the vanilla brewing and pressing reactions require
(DRINK_MAT and PRESS_LIQUID_MAT), checked on the structural material,
the seed material, and all growth materials. Cloth plants are detected
via the THREAD flag, edible plants via EDIBLE_RAW, and dye plants via
IS_DYE on mill/extract materials and growths.

Closes DFHack#5768
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Idea: getplants enhancements

1 participant