Thanks for the suggestion! What do you think, should I make that a per-player setting? Another idea would be to check whether ALT, CONTROL, or SHIFT was pressed while summoning the vehicle.
I think mix of both
- without CRTL = no rotation, with CTRL = rotation
- per-player setting to revert the logic
What I meant was using the setting to enable/disable the rotation completely, and to check for pressed keys only if rotation is enabled.
EDIT: This is not as simple as I originally thought. I use LuaSurface::can_place_entity()
to check whether the vehicle fits at the target position. However, there currently is no way to add orientation
to the arguments. While can_place_entity()
has an optional argument direction
, car prototypes do not support direction
at all.
I came to same conclusion, so for now I will use my patch, keeping in my mind to summon the car in safe distance of any entity. Maybe for car shaped nearly to square is this not so big issue, as for vehicles with bigger difference length vs width.
There may be another way: Use LuaSurface::can_place_entity()
first. If we find a non-colliding position, check LuaSurface:find_entities_filtered()
, passing on area
(which contains the top-left and bottom-right coordinates of a bounding box and, since Factorio 1.1.85, optionally orientation of the box). I'm already using find_entities_filtered
in Autodrive for determining whether a vehicle was crashing at the front or back. It's easier there because I know the other entity I'm looking for. Here, I still have to figure out what other filters to use. I guess this may work, but of course it would be more efficient if we could use orientation
with can_place_entity
.
Btw I have tried to position the car to the "wrong" position with no success. Do you know what will happen in this case (game crash / destruction of car or other entity) ?
I managed to place the car at a bad position! There was a combinator. My character was standing northwest of it, facing westwards. I then tried to summon a car directly to the right of the combinator, getting the message that there was no space. I then moved the cursor slightly right until the car could be summoned -- and it was overlapping the combinator a bit. As soon as I started to drive the car, the combinator would be damaged; but nothing bad would happen to combinator or car if the car was summoned to another position. However, the game won't complain about it, so the worst that can happen is that you'd damage another entity.