Make locomotive orientation consistent with create_entity

Post Reply
NiftyManiac
Long Handed Inserter
Long Handed Inserter
Posts: 90
Joined: Sat Jan 21, 2017 12:01 am
Contact:

Make locomotive orientation consistent with create_entity

Post by NiftyManiac »

Locomotives don't support direction, but have an orientation. Though orientation is listed as RW, it's not actually writable for locomotives, so you can't turn them around. However, create_entity will take a direction and correctly place a locomotive in that direction if possible.

So if I need to copy a locomotive, I need to take the orientation of the source locomotive, convert that to a direction, and create the new one with that direction. Not a huge problem, just kinda clumsy.

This was just a bit confusing to me, so it might help others if the api or the documentation clarified. Having create_entity take an optional orientation seems the cleanest solution. Alternatively, it'd be helpful to just specify that it will set direction even for entities that don't support reading it, and that locomotives' orientation is read-only.

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

Re: Make locomotive orientation consistent with create_entity

Post by Rseding91 »

There are a ton of properties that work on some entities and not others. Documenting them all would be a waste of time because they wouldn't be tied to the actual things and as we changed/added them it would just get outdated again.

It's like die(), damage(), and teleport() - they work on some things and not others.
If you want to get ahold of me I'm almost always on Discord.

NiftyManiac
Long Handed Inserter
Long Handed Inserter
Posts: 90
Joined: Sat Jan 21, 2017 12:01 am
Contact:

Re: Make locomotive orientation consistent with create_entity

Post by NiftyManiac »

Ok. I think adding orientation to create_entity would be very helpful, though.

I'm actually quite confused with how direction turns into orientation: if I'm trying to place a locomotive on a curved rail, with orientation=0.335, the directions east, southeast, west, and northwest all give me the correct direction, while the four other ones give me the wrong one. All I've gathered so far is that rotating the direction 90 degrees will correspond to the locomotive switching direction, but it seems to be unrelated to the actual named direction given to create_entity. Could you explain how this works?

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

Re: Make locomotive orientation consistent with create_entity

Post by Rseding91 »

Everything defaults to facing north (up). You adjust the direction to east and it will be facing east. Adjust it to south and it will face south.

What's not to understand about that?
If you want to get ahold of me I'm almost always on Discord.

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

Re: Make locomotive orientation consistent with create_entity

Post by Klonan »

Rseding91 wrote:Everything defaults to facing north (up). You adjust the direction to east and it will be facing east. Adjust it to south and it will face south.

What's not to understand about that?
It doesn't actually work like that in practice

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

Re: Make locomotive orientation consistent with create_entity

Post by Rseding91 »

Klonan wrote:
Rseding91 wrote:Everything defaults to facing north (up). You adjust the direction to east and it will be facing east. Adjust it to south and it will face south.

What's not to understand about that?
It doesn't actually work like that in practice
Yes it does, I tested it in 0.14.22 before writing the reply.
If you want to get ahold of me I'm almost always on Discord.

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

Re: Make locomotive orientation consistent with create_entity

Post by Klonan »

Rseding91 wrote:
Klonan wrote:
Rseding91 wrote:Everything defaults to facing north (up). You adjust the direction to east and it will be facing east. Adjust it to south and it will face south.

What's not to understand about that?
It doesn't actually work like that in practice
Yes it does, I tested it in 0.14.22 before writing the reply.
Not for locomotives

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

Re: Make locomotive orientation consistent with create_entity

Post by Rseding91 »

Ah, I was testing north/east. It does behave weirdly for the other directions. Fixed for 0.15.
If you want to get ahold of me I'm almost always on Discord.

Post Reply

Return to “Implemented mod requests”