Page 1 of 1

allow writing to LuaEntity.belt_to_ground_type

Posted: Mon Dec 04, 2017 3:34 am
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.

Re: allow writing to LuaEntity.belt_to_ground_type

Posted: Mon Dec 04, 2017 5:53 am
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.

Re: allow writing to LuaEntity.belt_to_ground_type

Posted: Mon Dec 04, 2017 6:07 am
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!