[2.0.23] entity_prototype_collides returns true but shouldnt

Bugs that are actually features.
Natha
Filter Inserter
Filter Inserter
Posts: 261
Joined: Sun Mar 15, 2015 1:48 pm
Contact:

[2.0.23] entity_prototype_collides returns true but shouldnt

Post by Natha »

I check a resource (only resource collision layer) against a cliff (not in resource collision layer) which should return false, but it returns true.
Am I missing something here?
Zaflis
Filter Inserter
Filter Inserter
Posts: 526
Joined: Sun Apr 24, 2016 12:51 am
Contact:

Re: [2.0.23] entity_prototype_collides returns true but shouldnt

Post by Zaflis »

They are likely going to need to see your source code. It takes time even for them to go through API's and figure out steps you are trying to do, of which you could have made typos too.
Natha
Filter Inserter
Filter Inserter
Posts: 261
Joined: Sun Mar 15, 2015 1:48 pm
Contact:

Re: [2.0.23] entity_prototype_collides returns true but shouldnt

Post by Natha »

Natha wrote: Sat Dec 07, 2024 9:59 pm I check a resource (only resource collision layer) against a cliff (not in resource collision layer) which should return false, but it returns true.
Am I missing something here?
There is no more information in the code:

Code: Select all

surface.entity_prototype_collides("iron-ore", cliff.position)
User avatar
boskid
Factorio Staff
Factorio Staff
Posts: 3942
Joined: Thu Dec 14, 2017 6:56 pm
Contact:

Re: [2.0.23] entity_prototype_collides returns true but shouldnt

Post by boskid »

Cannot reproduce.
12-11-2024, 13-48-01.png
12-11-2024, 13-48-01.png (183.92 KiB) Viewed 383 times
Natha
Filter Inserter
Filter Inserter
Posts: 261
Joined: Sun Mar 15, 2015 1:48 pm
Contact:

Re: [2.0.23] entity_prototype_collides returns true but shouldnt

Post by Natha »

I figured out that it happens on tiles adjacent to out-of-map, independent if there are any other entities:
grafik.png
grafik.png (243.33 KiB) Viewed 354 times

Code: Select all

for _, pos in ipairs(area_positions) do -- radius of 3 around the player; proto=copper-ore
	if surface.entity_prototype_collides(proto, pos, false) and surface.get_tile(pos[1], pos[2]).name ~= "out-of-map" then
		rendering.draw_circle{color={0, 0, 1}, radius=0.3, filled=true, target={pos[1]+0.5, pos[2]+0.5}, surface=surface, time_to_live=600}
	end
end
Attachments
test_0.0.1.zip
(1.07 KiB) Downloaded 14 times
User avatar
boskid
Factorio Staff
Factorio Staff
Posts: 3942
Joined: Thu Dec 14, 2017 6:56 pm
Contact:

Re: [2.0.23] entity_prototype_collides returns true but shouldnt

Post by boskid »

Try drawing the circles at the same position as the one given to the function and you will notice those positions are on the outside corners next to out of map tiles. Moving to not a bug.
Natha
Filter Inserter
Filter Inserter
Posts: 261
Joined: Sun Mar 15, 2015 1:48 pm
Contact:

Re: [2.0.23] entity_prototype_collides returns true but shouldnt

Post by Natha »

Thanks, didnt think about that...
But then: Is there a function that shows me how an entity prototype aligns with the tile grid, or do I have to evaluate that for myself? (2x2 entities are placed on that position without moving by [0.5, 0.5])
Post Reply

Return to “Not a bug”