Redstone Pen

Redstone Pen

6M Downloads

[FABRIC v1.5.31] TPx family of functions giving pulses of incorrect length

Delta-official opened this issue ยท 3 comments

commented

I have the following code in an RLC:

WAIT = TP1(G, IF(G == 14, (8 + 3) * 20, 4))
R = WAIT.FE

As shown in the screenshot, the time is correctly set to 220, but the length of the actual pulse is around 1-2 ticks, which is shown by a lamp pulsing (See picture 2)
image
The whole circuit looks like this.
image
The first RLC is simply mimicking the signal while doing a basic signal dropoff simulation after some time (The timer works perfectly fine in this case)

WAIT = TP1(G, 5 * 20)
B = WAIT.FE - 1

The modpack used to test this is Fabulously Optimized 5.4.1

commented

Hi, ty for the details and the images. Let's quickly double check what the behaviour you expected is, so that we know if it is a code bug or something that the documentation does not clarify.

WAIT = TP1(G, IF(G == 14, (8 + 3) * 20, 4))
R = WAIT.FE

What I read from the code:

  • TP1 starts when G has a transition from OFF->ON (0 to >0).

  • TP1 has a preset time of 220 ticks as long G is 14, otherwise 4 ticks.

  • WAIT stores the output of TP1, which is 15 as long as the timer runs, 0 if the timer has expired.

  • WAIT.FE triggers a tick after WAIT has a transition from ON->OFF (>0 to 0, that is after TP1 has expired).

  • In essence, without having tested it explicitly, I would expect that the Lamp is on for a short time after 220 ticks (or 4 ticks respectively depending on the signal G power). If G changes while the timer is running, the timer triggers earlier, as the preset time (PT) is checked and updated every time the RLC calculates.

Is that what you see, or does the behaviour differ, or did you intend something else?

Cheers,-

commented

Oky, ty for the feedback, I added a note for the latest mod/MC versions. Cheer's;;

commented

The PT update mechanic does indeed seem to have been the problem!
Since I used a single tick output on the first RLC (or well, it would be the same with a button), it would set PT to 220 and then immediately switch to 4 since the signal would disappear. This is pretty confusing and the current docs are missing this, so it would be good to add it.