Detecting that a side loading belt has stopped moving
Detecting that a side loading belt has stopped moving
B is stalled if B, C, and E are full (4 items)
A is stalled if A and C are full (4 items) and B+E adds up to at least 4 items
Can anyone suggest a better mechanism to detect this more reliably and/or sooner?
PS: I already have logic to deal with A, B, E being part of curved belts with a capacity different from 4 items, so don't worry about that aspect.
PPS: I know that can_insert_at() could give me more granular info than just checking for a full transport line, letting me detect an item sitting at the end of a belt before the belt fills up, but it is not performant enough for my needs.
Re: Detecting that a side loading belt has stopped moving
[Edit: ugh, sorry, I overlooked you're looking for modding, not for constructing. Sorry. But may be you get an idea to indirectly find the information you seek. As far as I remember, the devs said it's not possible to build the detection you seek into the game itself, because the belt system simply doesn't provide the information if a specific belt piece is moving or not. It's built this way for performance reasons. May be you keep it like that and let the player build some detection himself with the help of circuit networks.]
As far as I thought about "is a belt moving or not?" some time ago, I came to this solution. It's independent of sideloading, because as far as I see, sideloading has nothing to do with some belt moving or not.
- take 2 consecutive pieces of belt
- wire the downstream piece (1) and set it to 'read belt content', hold mode
- wire the upstream piece (2) and set it to 'read belt content', pulse mode
the belt is moving, if:
- the last pulse from belt 2 is less than <short timout, probably 10-30> ticks ago
the belt is stalled, if:
- belt 1 has 8 items AND the last pulse from belt 2 is more than <short timeout, probably 10-30> ticks ago
the belt is empty, if:
- belt 1 has 0 items and the last pulse from belt 2 is more than <long timeout, probably 60-300> ticks ago
You need a counter to count the ticks since the last pulse (1 combinator) and one or two more to create the various combined conditions. Probably one to decide on the 8 or not 8 items, and one to combine the counter with the previous decider, so it's 3 in the end.
As far as I thought about "is a belt moving or not?" some time ago, I came to this solution. It's independent of sideloading, because as far as I see, sideloading has nothing to do with some belt moving or not.
- take 2 consecutive pieces of belt
- wire the downstream piece (1) and set it to 'read belt content', hold mode
- wire the upstream piece (2) and set it to 'read belt content', pulse mode
the belt is moving, if:
- the last pulse from belt 2 is less than <short timout, probably 10-30> ticks ago
the belt is stalled, if:
- belt 1 has 8 items AND the last pulse from belt 2 is more than <short timeout, probably 10-30> ticks ago
the belt is empty, if:
- belt 1 has 0 items and the last pulse from belt 2 is more than <long timeout, probably 60-300> ticks ago
You need a counter to count the ticks since the last pulse (1 combinator) and one or two more to create the various combined conditions. Probably one to decide on the 8 or not 8 items, and one to combine the counter with the previous decider, so it's 3 in the end.
Re: Detecting that a side loading belt has stopped moving
Sadly, this is for a difficult mod, not something the player would want to build themselves.
If I could use the circuit network, I'd just check if the belt has an item on it and has pulsed in the last 32, 16, or 10 ticks. This is so easy to build in-game and soooo difficult to do with a mod :/
If I could use the circuit network, I'd just check if the belt has an item on it and has pulsed in the last 32, 16, or 10 ticks. This is so easy to build in-game and soooo difficult to do with a mod :/