Skip to content

new script: item-uses - show all workshop uses for selected item#1581

Open
sizzlins wants to merge 2 commits intoDFHack:masterfrom
sizzlins:feature/item-uses
Open

new script: item-uses - show all workshop uses for selected item#1581
sizzlins wants to merge 2 commits intoDFHack:masterfrom
sizzlins:feature/item-uses

Conversation

@sizzlins
Copy link
Copy Markdown

Summary

Adds a new DFHack command item-uses that introspects the currently selected item and lists every workshop and task that can use it.

Usage

Select any item in-game (from inventory, stockpile, or trade screen), then run:
item-uses

Example Output

`
=== Uses for: steel bars ===
Type: BAR | Material: INORGANIC:STEEL

Metalsmith's forge:
- Forge metal items
- Forge weapons/armor/items
- forge angir body
- forge angir strings
...
Smelter:
- Melt metal item
Trade depot:
- Trade with merchants

Total: 142 uses across 6 workshops
`

Features

  • Material flag inspection: IS_METAL, WOOD, LEATHER, IS_DYE, EDIBLE_COOKED, etc.
  • Plant flag analysis: DRINK, MILL, DRY, THREAD with proper PLANT vs PLANT_GROWTH distinction
  • Material reaction products: DRINK_MAT, DYE_MAT, CHEESE_MAT, SOAP_MAT, etc.
  • Full reaction matching: Scans all game reactions and matches the primary reagent against the item
  • Dynamic workshop resolution: Uses df.workshop_type/df.furnace_type enums for version-safe workshop names
  • Smart filtering: Skips container/tool reagents and secondary inputs to avoid false positives
  • Raw vs finished awareness: Raw materials show crafting uses; finished goods show 'Encrust with gem' and 'Melt metal item' instead

Technical Details

  • Handles building fields stored as vectors (r.building.type[idx])
  • Builds raw material type table safely to handle nil enum values across DF versions
  • Only matches the first non-container reagent per reaction to avoid secondary ingredient false positives
  • Growth-aware: EDIBLE_GROWTH only shown when the growth's own material has EDIBLE_COOKED

Adds a new DFHack command 'item-uses' that introspects the selected item and
lists every workshop and task that can use it. Features:

- Material flag inspection (IS_METAL, WOOD, LEATHER, IS_DYE, etc.)
- Plant flag analysis (DRINK, MILL, DRY, THREAD, etc.)
- Material reaction product discovery (DRINK_MAT, DYE_MAT, CHEESE_MAT, etc.)
- Full reaction/workshop matching against all game reactions
- Dynamic workshop name resolution using df.workshop_type/df.furnace_type enums
- Smart reagent filtering to avoid false positives from containers and
  secondary reagents
- Proper gating of 'make items' uses to raw materials only (finished goods
  like armor and furniture correctly show 'Encrust' and 'Melt' instead)
- Growth-aware: distinguishes PLANT vs PLANT_GROWTH for accurate results

Usage: select an item in-game, then run 'item-uses' from the DFHack console.
@sizzlins
Copy link
Copy Markdown
Author

image

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.

1 participant