Skip to content

feat: quality system compatibility — matter source/void quality filtering + entity health scaling#61

Merged
jodli merged 4 commits into
masterfrom
identify-quality-system-compatibility-issues-in-game
Jun 30, 2026
Merged

feat: quality system compatibility — matter source/void quality filtering + entity health scaling#61
jodli merged 4 commits into
masterfrom
identify-quality-system-compatibility-issues-in-game

Conversation

@jodli

@jodli jodli commented Jun 30, 2026

Copy link
Copy Markdown
Owner

Artifacts | Task | PR Walkthrough

What problems was I solving

Space Age players with CreativeMod encountered four quality-system failures in Factorio 2.0+:

  1. Health regression on pickup — Picking up a legendary entity and re-placing it left it at 40% HP (uncommon 76%, rare 62%, epic 52%, legendary 40%). The repair-mined-item cheat called entity.prototype.get_max_health() which always returns the normal-quality ceiling, not the quality-scaled instance maximum.
  2. Healer wand broken for quality — The healer wand used the same prototype getter, so it could never heal a legendary entity above 40% of its actual max health.
  3. Matter Source stripped quality from output — The provider spine in item-providers-util.lua accepted a {name, quality} filter table but immediately passed only filter.name downstream, producing normal-quality stacks regardless of what quality the player configured.
  4. Matter Void ignored filter quality — The removal path matched by item name only; it would void all qualities of an item even when a specific quality tier was selected.
  5. Creative Lab stopped working in Factorio 2.1 — Science packs are no longer "tool" items; the lab's input list was built by iterating data.raw["item"] and matching subgroup == "science-pack", a subgroup that no longer reliably maps to lab inputs.

What user-facing changes did I ship

  • scripts/cheats.lua — Repair-mined-item and entity-full-health cheat restore to quality-scaled max HP
  • scripts/magic-wand-healer.lua — Healer wand now heals quality entities to their actual 100%
  • scripts/item-providers-util.lua — Matter Source outputs items at the configured quality; Matter Void removes only the configured quality tier (or all tiers if no quality is set)
  • data-final-fixes.lua — Creative Lab accepts all science packs again
  • Autofill Requester Chest removed — it was already non-functional (tick was commented out, called an undefined helper); removing it avoids confusion and saves prototype/locale/setting slots

How I implemented it

Step 1 — Quality-aware health restoration

Added scripts/util.lua +10: a single util.restore_entity_to_full_health(entity) helper that sets entity.health = entity.max_health. The entity.max_health property is Factorio 2.0's quality-aware instance ceiling — it already folds in the quality multiplier.

Wired through:

Step 2 — Thread quality through the matter provider spine

scripts/item-providers-util.lua: The filter_item_name string parameter was replaced with a {name, quality?} filter table throughout all internal helpers. Every output stack, duplicate call, slot fill, transport-line fill, and ground-drop path now receives and passes on the full object.

Matter Void semantics codified: filter quality set → remove only that quality; filter present but quality nil → remove all qualities of that name; no filter → remove everything.

Callers updated to stop splitting off .name:

Step 3 — Standalone edge fills

Fills that synthesize stacks directly (bypassing item-providers-util) were updated:

Step 4 — Creative Lab fix + dead code removal

data-final-fixes.lua and prototypes/technology.lua: Input lists now derived from data.raw["lab"][*].inputs (excluding the creative and void labs themselves) rather than the science-pack subgroup. The void-technology ingredient list is built the same way.

Dead code removed in full:

  • scripts/autofill-requester-chest.lua deleted (99 lines)
  • scripts/creative-chest.lua and scripts/creative-provider-chest.lua deleted (16 lines each)
  • scripts/events.lua −128 lines of autofill hook registrations
  • Autofill prototype, item, recipe, setting, defines, and locale strings removed from 5 additional files

Deviations from the plan

No plan file found in task directory. The work was guided by a structure outline (05-structure-outline-quality-compatibility.md) and design discussions. The implementation follows the outline phases closely.

How to verify it

Setup

git checkout identify-quality-system-compatibility-issues-in-game

Automated Tests

uv run verify.py all
# Expected: RESULT: all=PASS (27 behavior assertions, static, load)

Manual Testing

  • Place a legendary assembling machine → mine it → re-place it → check HP is 100%
  • Use the healer wand on a legendary belt → verify it heals to full (not 40%)
  • Place a Matter Source, set filter to legendary iron-plate → check output chest contains legendary stacks
  • Place a Matter Void, set filter to rare iron-plate, put normal + rare iron-plate in adjacent chest → verify only rare is removed
  • Place a Matter Void, set filter to iron-plate (no quality) → verify both normal and rare are removed
  • Place a Creative Lab → verify it auto-fills with science packs and can research

Description for the changelog

Fix quality-system compatibility: entity health scaling (repair/healer), Matter Source/Void quality filtering, and Creative Lab refill broken in Factorio 2.1; remove non-functional Autofill Requester Chest.

jodli and others added 4 commits July 1, 2026 00:18
Swap the level-0 entity.prototype.get_max_health() reads on the
"restore to full" paths to the quality-aware instance read
entity.max_health, via a shared util.restore_entity_to_full_health
helper. Covers repair-mined-item, the entity full-health cheat
(write + "is it full?" comparison), and the healer wand (character
flat bonuses layered on the quality-aware ceiling). A legendary
entity now restores to 100%, not the normal-quality value.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Convert item-providers-util's filter_item_name string parameter to a
quality-bearing {name, quality} filter object threaded end-to-end, and
stop the four matter shims (item-void, item-source, duplicator,
random-item-source) from stripping .name/.quality. Output, duplicate,
slot-fill, transport-line, and ground-drop stacks now carry quality;
removal paths compare quality.

Matter Void semantics: filter quality set -> that quality only; filter
present but quality unset -> all qualities of the name; no filter ->
everything. Source/Duplicator/Random output at the configured quality.

Adds verify.py behavior assertions matter_source_outputs_quality,
matter_void_targets_quality, and matter_void_unset_quality_removes_all.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Thread quality through the fills that synthesize their own item stacks
rather than going through the item-providers-util engine: the old
creative chest fill, the Duplicating Chest locked-item fill and
copy-paste insert (via a new locked_item_quality field), the Creative
Lab fill, the Autofill Requester Chest fill, and the keep-last-item
cheat. Each now produces a stack carrying the configured/source
quality instead of defaulting to normal.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Creative Lab
- Build the runtime refill list from the lab's own lab_inputs instead of
  the "tool" prototype type, which Factorio 2.1 removed (science packs are
  now plain items), so the lab auto-refills again.
- Derive the lab inputs and the void-technology ingredients from real labs'
  inputs rather than the "science-pack" subgroup, keeping non-pack items
  that merely share that subgroup (coin, the "science" pictogram) out. Both
  must change together: the void technology required those items and the
  buggy lab was the only lab that satisfied it.

Dead code / migration
- Delete the orphaned creative-chest.lua and creative-provider-chest.lua
  (never required, their tick() functions were never called).
- Remove the v1.8.1 old->new chest conversion migration; no save predates it.

Autofill Requester Chest
- Remove the feature entirely (script, require, tick, clear-on-mine,
  storage, register hooks, prototypes, item, recipe, setting, defines, and
  locale). It was already dead: its tick was commented out and called an
  undefined helper.

verify.py static + full behavior suite pass.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@jodli jodli merged commit 52f0dfa into master Jun 30, 2026
2 checks passed
@jodli jodli deleted the identify-quality-system-compatibility-issues-in-game branch June 30, 2026 22:28
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