[0.12.29] [Twinsen] find_entity for curved-rail

This subforum contains all the issues which we already resolved.
Post Reply
reofarp
Burner Inserter
Burner Inserter
Posts: 9
Joined: Fri Mar 11, 2016 10:45 pm
Contact:

[0.12.29] [Twinsen] find_entity for curved-rail

Post by reofarp »

I'm creating curved rail at {0,0} facing north using the game or

Code: Select all

game.player.surface.create_entity({name="curved-rail", position={0,0}, direction=0})
but then `find_entity` used like this

Code: Select all

game.player.surface.find_entity("curved-rail", {0,0})
only gives me nil back.

I verified that the rail coordinates stayed the same after creation, no snapping or anything. With other rail types it works.
Interestingly if i use the coordinates {1,2} or {1,3} it finds the curved rail, which is quite weird.
Is there some sort of intentional rule behind this coordinate magic (as with diagonal rail in my other bug report) or is this a bug?

User avatar
Klonan
Factorio Staff
Factorio Staff
Posts: 5026
Joined: Sun Jan 11, 2015 2:09 pm
Contact:

Re: [0.12.29] find_entity for curved-rail

Post by Klonan »

Use

Code: Select all

/c game.local_player.print(game.local_player.selected.position.x..", "..game.local_player.selected.position.y)
to see the actual co-ordinate position,
It might snap to another tile position depending on the orientation

EDIT: just tested it and it seems to be a bug alright
something to do with the secondary bounding box

reofarp
Burner Inserter
Burner Inserter
Posts: 9
Joined: Fri Mar 11, 2016 10:45 pm
Contact:

Re: [0.12.29] find_entity for curved-rail

Post by reofarp »

I had it wrong with the other rail types: diagonal straight rail is also affected: here I can't even find coordinates for which find_entity returns anything.

kovarex
Factorio Staff
Factorio Staff
Posts: 8058
Joined: Wed Feb 06, 2013 12:00 am
Contact:

Re: [0.12.29] find_entity for curved-rail

Post by kovarex »

The position is usually changed, so it snappes to grid. In other word, the position of the result entity might be different than the provided.
The create_entity command returns LuaEntity, so you can check it by something like this:

Code: Select all

local rail = game.player.surface.create_entity({name="curved-rail", position={0,0}, direction=0})
game.player.print(rail.position.x .. ", " .. rail.position.y)

User avatar
Klonan
Factorio Staff
Factorio Staff
Posts: 5026
Joined: Sun Jan 11, 2015 2:09 pm
Contact:

Re: [0.12.29] find_entity for curved-rail

Post by Klonan »

kovarex wrote:The position is usually changed, so it snappes to grid. In other word, the position of the result entity might be different than the provided.
The create_entity command returns LuaEntity, so you can check it by something like this:

Code: Select all

local rail = game.player.surface.create_entity({name="curved-rail", position={0,0}, direction=0})
game.player.print(rail.position.x .. ", " .. rail.position.y)
This returns the position incorrectly, for curved rail created at 0,0 it reads entity position as 0,0 but you can only find it with find entity at 1,2

Image

Rseding91
Factorio Staff
Factorio Staff
Posts: 12139
Joined: Wed Jun 11, 2014 5:23 am
Contact:

Re: [0.12.29] find_entity for curved-rail

Post by Rseding91 »

kovarex wrote:The position is usually changed, so it snappes to grid. In other word, the position of the result entity might be different than the provided.
The create_entity command returns LuaEntity, so you can check it by something like this:

Code: Select all

local rail = game.player.surface.create_entity({name="curved-rail", position={0,0}, direction=0})
game.player.print(rail.position.x .. ", " .. rail.position.y)
find_entity internally uses entity->collide(position) which internally uses this->boundingBox.collide(position) and doesn't check against the secondary bounding box that curved rails use :)
If you want to get ahold of me I'm almost always on Discord.

kovarex
Factorio Staff
Factorio Staff
Posts: 8058
Joined: Wed Feb 06, 2013 12:00 am
Contact:

Re: [0.12.29] find_entity for curved-rail

Post by kovarex »

Ah, so the virtual method collide is only implemented for collision with bounding box, but not for a point. That would most probably solve it. (You can do it robert :))

kovarex
Factorio Staff
Factorio Staff
Posts: 8058
Joined: Wed Feb 06, 2013 12:00 am
Contact:

Re: [0.12.29] [Twinsen] find_entity for curved-rail

Post by kovarex »

Fixed for 0.12.30

Post Reply

Return to “Resolved Problems and Bugs”