Skip to content

fix(can_place_entity): allow offshore pumps on land at the shore (Factorio 2.0) - #434

Open
hashbender wants to merge 1 commit into
JackHopkins:mainfrom
hashbender:fix/offshore-pump-placement-on-land
Open

hashbender wants to merge 1 commit into
JackHopkins:mainfrom
hashbender:fix/offshore-pump-placement-on-land

Conversation

@hashbender

Copy link
Copy Markdown

Problem

can_place_entity/server.lua refuses an offshore pump unless the tile at the position is water:

if entity == "offshore-pump" then
    local tile = player.surface.get_tile(x, y)
    if not tile.prototype.name:match("water") then
        error("Cannot place the entity at the specified position due to lack of water.")
    end
end

In Factorio 2.0 an offshore pump stands on land at the edge of water. Its prototype collides with objects but not with water, and its tile_buildability_rules require water in front of it. So the tile under a valid pump is sand, grass or dirt. A scan along one shore found 23 valid placements on land and none on water. can_place_entity(Prototype.OffshorePump, ...) therefore returns False for every spot where the pump can actually go. Meanwhile place_entity, which already searches for a land tile next to water, places it without trouble. The manual adds to the confusion by saying "Offshore pumps require water tiles".

Fix

  • can_place_entity/server.lua: drop the water-tile test and ask surface.can_place_entity with the entity's direction. When the game says no, the error now reads "it must be placed at the edge of water". The general collision check and the existing avoid_entity check are unchanged.
  • can_place_entity/agent.md: "Offshore pumps are placed on land at the edge of water (Factorio 2.0), not on water tiles".

Testing

  • New test_can_place_offshore_pump_at_shore in tests/actions/test_can_place.py: places a pump at the nearest water with place_entity, picks it up, and checks that can_place_entity accepts the same position in at least one direction. It needs a server and is left to the factorio-test workflow; I haven't run it. On main I'd expect it to fail with "lack of water".
  • luac -p parses the changed Lua. ruff 0.11.13 and prettier are clean.

🤖 Generated with Claude Code

…torio 2.0)

can_place_entity refused an offshore pump unless the tile at the position was
water. In 2.0 the pump stands on land at the edge of water, so every valid
spot was refused, while place_entity (which already searches land tiles next
to water) placed the pump fine.

Ask surface.can_place_entity instead, with the entity's direction, and say
in the error that the pump goes at the edge of water. Update the manual line.

Tests: test_can_place_offshore_pump_at_shore places a pump with place_entity,
picks it up and checks can_place_entity accepts the same position.

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