LuaSurface::entity_prototype_collides incorrect with curved rails
Posted: Sat Mar 16, 2024 11:00 pm
I'm assuming this is because of the secondary collision box that curved rails have, but when the curved part collides with something and the straight part does not, the method returns the incorrect result.
I don't expect this to be fixed for 1.1.x, but I at least wanted to make sure this was made aware of in case it is relevant for 2.0.
To reproduce, place a curved rail ghost like this:
Then, run the following command while selecting the curved rail with your mouse cursor:
There is a workaround for this specific scenario, which is the LuaSurface::can_place_entity method instead, however I have been told that the underlying c++ function is used for autoplace, so if anyone ever tries to give curved rails an autoplace then this would be a real issue.
I don't expect this to be fixed for 1.1.x, but I at least wanted to make sure this was made aware of in case it is relevant for 2.0.
To reproduce, place a curved rail ghost like this:
Then, run the following command while selecting the curved rail with your mouse cursor:
Code: Select all
/c local entity = game.player.selected
game.print(game.player.surface.entity_prototype_collides(entity.ghost_prototype, entity.position, false, entity.direction))
-- false
Code: Select all
/c local entity = game.player.selected
game.print(not game.player.surface.can_place_entity{name = entity.ghost_name, position = entity.position, direction = entity.direction})
-- true