Skip to content

fix(game_types): use Factorio 2.0 names for rails, barrel and rocket items; add missing 2.0 entity statuses - #431

Open
hashbender wants to merge 1 commit into
JackHopkins:mainfrom
hashbender:fix/prototype-names-factorio-2
Open

hashbender wants to merge 1 commit into
JackHopkins:mainfrom
hashbender:fix/prototype-names-factorio-2

Conversation

@hashbender

Copy link
Copy Markdown

Problem

A few Prototype members use names that don't exist in Factorio 2.0, and some 2.0 items have no member. craft_item, place_entity, insert_item and extract_item only take Prototype members, and get_entities skips any entity whose name has no member. So:

  • Rails: Prototype.Rail = "rail" is an item in 2.0 (it places a straight-rail). There is no rail entity. Placed rails are straight-rail, curved-rail-a, curved-rail-b or half-diagonal-rail, none of which has a member, so get_entities drops them and rotate_entity raises a KeyError on prototype_by_name[entity.name].
  • Barrel: Prototype.EmptyBarrel = "empty-barrel". 2.0 calls the item barrel, so craft_item(Prototype.EmptyBarrel) sends a name that doesn't exist.
  • Missing items: explosives, cliff-explosives, landfill and repair-pack exist in 2.0 (all early-game technologies) but can't be crafted, inserted or extracted.
  • Removed item: Prototype.RocketControlUnit (rocket-control-unit) has no item or recipe in 2.0.
  • Misspelling: Prototype.CoalLiquifaction = "coal-liquifaction". The recipe is coal-liquefaction (RecipeName.CoalLiquefaction already spells it right).
  • Rocket: Prototype.Rocket = "rocket" maps to ent.Rocket (a silo rocket). In 2.0 rocket is the rocket launcher's ammo item; the silo's rocket is the entity rocket-silo-rocket.
  • Entity statuses: EntityStatus lacks three 2.0 values from defines.entity_status: waiting_for_more_items, waiting_for_rockets_to_arrive and recipe_is_parameter. An entity in one of these states fails pydantic validation, and get_entities prints "Could not create ..." and drops it.

All RecipeName values are valid 2.0 recipe names; only its coal-liquefaction comment was wrong.

Fix

  • Prototype:
    • Add StraightRail, CurvedRailA, CurvedRailB and HalfDiagonalRail (class ent.Rail). Rail stays as the item.
    • Add Barrel = "barrel". EmptyBarrel becomes an alias of it, so existing code keeps working.
    • Add Explosives, CliffExplosives, Landfill and RepairPack (items, class None).
    • Remove RocketControlUnit.
    • Rename CoalLiquifaction to CoalLiquefaction ("coal-liquefaction"). Nothing in the repo used the old name, so no alias is kept; Prototype.CoalLiquifaction now raises AttributeError ... Did you mean: CoalLiquefaction? through the existing metaclass.
    • Rocket maps to ent.Ammo, like the magazines.
  • EntityStatus: add WAITING_FOR_MORE_ITEMS, WAITING_FOR_ROCKETS_TO_ARRIVE and RECIPE_IS_PARAMETER. Existing members are unchanged.
  • Comments: RecipeName.CoalLiquefaction now says it makes heavy oil, light oil and petroleum gas from coal, heavy oil and steam. The "These are recipes, not prototypes" comment is removed from SolidFuel, which is an item.
  • Callers of the removed names: tests/entities/test_rockets.py used rocket-control-unit / Prototype.RocketControlUnit; it now uses processing-unit, which the 2.0 rocket-part recipe takes. tests/render/test_assembler_recipes.py uses Prototype.Barrel / "barrel" and drops the RCU entries. The Prototype listing in condensed_prompts.py drops RocketControlUnit.

Testing

  • New tests/unit/test_prototype_names.py (server-free, 15 tests):
    • Every Prototype value is an item or fluid of a Factorio 2.0.73 headless server (base mod only), a placed-rail entity, one of the two recipe-name members, or one of FLE's group names.
    • The barrel, removed-RCU, coal-liquefaction, rail, new-item and rocket cases.
    • Every defines.entity_status name in the 2.0.73 Lua API is an EntityStatus value.
    • 14 of the 15 fail on main; all pass on this branch.
  • tests/unit passes (19 tests).
  • tests/entities/test_rockets.py and tests/render/test_assembler_recipes.py need a server. I only checked that they collect (13 tests); I haven't run them.
  • ruff 0.11.13 format/check clean.

Notes

  • place_entity(Prototype.Rail) still fails: the Lua checks prototypes.entity["rail"] and uses one name for both the item and the entity. Fixing that means mapping an item to its place_result in place_entity/server.lua. I've left it out of this PR because I couldn't run it against a server here.
  • Landfill and CliffExplosives can now be crafted, inserted and extracted. FLE has no tool to place a tile or throw a capsule, so they can't be used on the map yet.
  • The system prompt includes game_types.py, so the Prototype listing grows by about 10 lines.

🤖 Generated with Claude Code

…items

- Prototype: add StraightRail, CurvedRailA, CurvedRailB and HalfDiagonalRail
  so placed rails decode (the "rail" item places a straight-rail in 2.0).
- Prototype.Barrel = "barrel" (2.0 name); EmptyBarrel stays as an alias.
- Add Explosives, CliffExplosives, Landfill and RepairPack.
- Remove RocketControlUnit (no such item or recipe in 2.0).
- Rename CoalLiquifaction to CoalLiquefaction ("coal-liquefaction").
- Prototype.Rocket is the rocket launcher's ammo item: class ent.Ammo.
- EntityStatus: add waiting_for_more_items, waiting_for_rockets_to_arrive and
  recipe_is_parameter, so entities in those states are not dropped.
- Fix the coal-liquefaction and solid-fuel comments.
- Tests: server-free check of every Prototype value against the items and
  fluids of a 2.0.73 server, and of EntityStatus against defines.entity_status.
  Update the rocket and assembler-recipe tests that used the removed names.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

This branch has not been deployed

No deployments
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