[Twinsen][1.0.0] can_place_entity distance calculation seems to be wrong [Updated with more info]

This subforum contains all the issues which we already resolved.
Post Reply
DunRaider
Burner Inserter
Burner Inserter
Posts: 5
Joined: Wed Oct 07, 2020 7:45 am
Contact:

[Twinsen][1.0.0] can_place_entity distance calculation seems to be wrong [Updated with more info]

Post by DunRaider »

Hi - thanks for a great game. :)

What I try to do:
I am developing a tool which (hopefully) will make it a lot easier for players to get into tool assisted speed runs. I therefore need to be able to place buildings as far away as the default game will allow me.

My problem
In connection with trying to figure out how to find the furthest distance in a simple way I stumbled upon a rather strange thing. When I find what seems to be the furthest distance I can build something can_place_entity won't allow me to - it seems to think I am too far away.

Reproduce the issue
I have attached a sample which shows the issue. The script tries to place a steam engine (will be provided by the script) at location 4.5, 11.5. This is possible in the game (as seen in the attached picture), but will not be allowed by can_place_entity. If you use /c game.player.teleport({0, 0.5 }) it will place the steam engine, so it seems that can_place_entity thinks the character needs to be closer than is actually the case.

Disclaimer
It might be that I am simply using can_place_entity incorrectly - please correct my ways if that is the case. :)

Map
This is not map specific, but the location can of course not be blocked. Here is a map:

>>>eNpjZICDBnsQ5mBJzk/MgfFAmCs5v6AgtUg3vygVWZgzuag0J
VU3PxNVcWpeam6lblJiMYpijsyi/Dx0E1iLS/LzUEVKilJTi5FFu
EuLEvMyS3PR9TIwbhKZuLqhRY4BhP/XMyj8/w/CQNYDoF9AmIGxA
aISKAYDrMk5mWlpDAwKjkDsBJJmZGSsFlnn/rBqij0jRI2eA5TxA
SpyIAkm4glj+DnglFKBMUyQzDEGg89IDIilJUAroKo4HBAMiGQLS
JKRsfft1gXfj12wY/yz8uMl36QEe0ZDV5F3H4zW2QEl2UH+ZIITs
2aCwE6YVxhgZj6wh0rdtGc8ewYE3tgzsoJ0iIAIBwsgccCbmYFRg
A/IWtADJBRkGGBOs4MZI+LAmAYG32A+eQxjXLZH9wcwIGxAhsuBi
BMgAmwh3GWMEKZDvwOjgzxMVhKhBKjfiAHZDSkIH56EWXsYyX40h
2BGBLI/0ERUHLBEAxfIwhQ48YIZ7hpgeF5gh/Ec5jswMoMYIFVfg
GIQHkgGZhSEFnBgRmQ3ULJYvs1yDwA+LqF5<<<
Attachments
Screenshot 2020-10-07 11.05.55.png
Screenshot 2020-10-07 11.05.55.png (4.15 MiB) Viewed 3717 times
Can_place_entity_bug.zip
(1.02 KiB) Downloaded 108 times
Last edited by DunRaider on Wed Oct 07, 2020 10:57 am, edited 1 time in total.

Bilka
Factorio Staff
Factorio Staff
Posts: 3135
Joined: Sat Aug 13, 2016 9:20 am
Contact:

Re: [1.0.0] can_place_entity distance calculation seems to be wrong

Post by Bilka »

For now, you can work around this discrepancy by removing the direction parameter from can_place_entity so that it defaults to north. This will result in the same behaviour as the player reach check, which currently ignores the entity direction.
I'm an admin over at https://wiki.factorio.com. Feel free to contact me if there's anything wrong (or right) with it.

DunRaider
Burner Inserter
Burner Inserter
Posts: 5
Joined: Wed Oct 07, 2020 7:45 am
Contact:

Re: [1.0.0] can_place_entity distance calculation seems to be wrong

Post by DunRaider »

Hi Bilka,

Thanks for the fast reply. That seems to solve it.. strange.

Is this due to the fact, that I actually shouldn't be able to place it with east or west as the direction if the max distance of 10 rule was applied when placing buildings, which are not square? When I place the steam engine I am not able to interact with it, given that the character is actually further away than 10.

DunRaider
Burner Inserter
Burner Inserter
Posts: 5
Joined: Wed Oct 07, 2020 7:45 am
Contact:

Re: [1.0.0] can_place_entity distance calculation seems to be wrong

Post by DunRaider »

I have tried the fix in a more realistic scenario and unfortunately the fix won't help.

I have altered the sample to place two steam engines:
1. at location 4.5, 11.5
2. at location 4.5, 8.5

This results in the first being placed and the next being blocked by can_place_entity, given that it wouldn't be possible to place a north facing steam engine at that location - which in all fairness seems to be the correct behavior.
Attachments
Can_place_entity_bug.zip
(1.09 KiB) Downloaded 113 times

Twinsen
Factorio Staff
Factorio Staff
Posts: 1330
Joined: Tue Sep 23, 2014 7:10 am
Contact:

Re: [Twinsen][1.0.0] can_place_entity distance calculation seems to be wrong [Updated with more info]

Post by Twinsen »

Fixed in Version: 1.1.0, thanks for the report.

Note that distance calculation is made in a weird way so that rotating a non-sqare entity doesn't make it go out of range. You should still send the direction correctly and everything should work consistently. If there's any problem after the update, let me know.

Post Reply

Return to “Resolved Problems and Bugs”