allow writing to LuaEntity.belt_to_ground_type

Things that already exist in the current mod API
Post Reply
User avatar
Therax
Filter Inserter
Filter Inserter
Posts: 470
Joined: Sun May 21, 2017 6:28 pm
Contact:

allow writing to LuaEntity.belt_to_ground_type

Post by Therax »

It would be nice if writing to belt_to_ground_type could change the belt direction of an underground belt.
To my understanding, when a player selects an underground belt entity and presses 'R', the following happens:
  • belt_to_ground_type is changed to the opposite value
  • the entity's direction is set to the opposite direction
  • the same two operations are performed on the entity's neighbours (a single partner underground belt), if it is non-nil
Currently, belt_to_ground_type is read-only, and only direction can be written. Writing to direction changes the orientation of the "hood", disrupting any existing connection. If there's another way I've missed to programmatically change the direction of the belt for an underground belt without affecting the orientation of the entity, I'd be happy to hear about that too. Currently, my mod deals with this situation by calling destroy on the existing entity, and then calling create_entity with appropriate direction and type parameters, which is messy and inconvenient since the entity construction animation plays, other references to the underground belt entity become invalid, etc.
Miniloader — UPS-friendly 1x1 loaders
Bulk Rail Loaders — Rapid train loading and unloading
Beltlayer & Pipelayer — Route items and fluids freely underground

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

Re: allow writing to LuaEntity.belt_to_ground_type

Post by Bilka »

does 53610 do what you want? To my understanding pressing r on an ug belt only chnages the in-output type, not direction. So rotate() should do what you want.
I'm an admin over at https://wiki.factorio.com. Feel free to contact me if there's anything wrong (or right) with it.

User avatar
Therax
Filter Inserter
Filter Inserter
Posts: 470
Joined: Sun May 21, 2017 6:28 pm
Contact:

Re: allow writing to LuaEntity.belt_to_ground_type

Post by Therax »

Bilka wrote:does 53610 do what you want? To my understanding pressing r on an ug belt only chnages the in-output type, not direction. So rotate() should do what you want.
It does sound like it should serve my needs, if it emulates what happens when a player hits 'R'. Generally the direction indicates which way the belt pushes items. So reversing an UG belt both changes the input/output, and inverts the direction. Thanks for the pointer!
Miniloader — UPS-friendly 1x1 loaders
Bulk Rail Loaders — Rapid train loading and unloading
Beltlayer & Pipelayer — Route items and fluids freely underground

Post Reply

Return to “Already exists”