CyclopsMC / IntegratedDynamics

A Minecraft mod to take full and automated control of your appliances.
http://cyclopsmc.github.io/IntegratedDynamics/
MIT License
126 stars 61 forks source link

Implement the RS Latch (Flip-Flop) #438

Open Gravlok opened 6 years ago

Gravlok commented 6 years ago
josephcsible commented 6 years ago

The Delayer already lets you do that: https://www.reddit.com/r/feedthebeast/comments/7h0w1c/comment/dqnjysm

That's pretty much the same way that PLCs do it, actually.

reddit
Integrated Dynamics Help... • r/feedthebeast
Set up a Delayer that holds a value from a single previous tick. Build a criterion like "shouldProduce := x < 95% and (x < 75% or...
rubensworks commented 6 years ago

Might be convenient to have some block that can do exactly this. Perhaps some time in the future, as you can indeed already do it with the Delayer.

StarkRG commented 6 years ago

It's not that hard to do with logic: active = (!active && startCondition) || (active && !stopCondition)

josephcsible commented 6 years ago

You can't do it with just logic; you do need the Delayer. To prevent infinite loops, variables aren't allowed to use their (non-delayed) value to calculate their value.

StarkRG commented 6 years ago

Ahh, fair enough, I'm using a redstone output and have a redstone reader for feedback.

josiah-roberts commented 5 years ago

@josephcsible It's very possible I'm just stupid, but I can't figure out how to do what you're talking about. Namely, shouldProduce = !stopCondition && (startCondition || producedLastTick) - I can't seem to figure out how to boot-strap this self-reference with the delayer. How can I define producedLastTick without having already defined the variable for shouldProduce... which requires producedLastTick....

josephcsible commented 5 years ago

You can get producedLastTick from the Delayer's list of previous outputs, which is available for use even before you give the Delayer an input.

KollinsPlays commented 4 years ago

The simple solution would be to add Logical Latches to the Logic Programmer.

I think what people want is to get the functionality of an EnderIO Power Monitor or a vanilla redstone "RS NOR Latch" without having to use external redstone or blocks. The delayer can be used to give you a similar result, but it uses different logic to perform that task.

A simple "Logical SR Latch" with Set (S) and Reset (R) inputs that outputs Q would work. As long as it toggles to True when Set is True and stays True even when Set is off, until Reset becomes True, it doesn't need to be more complex. The typical RS NOR latch we build is just the easiest way to get the function of a Logical SR Latch out of vanilla redstone anyhow,

Another useful one would be a "Logical T-Flop" that accepts a single input and toggles between staying True or staying False each time it gets an input. Again, we don't need all the function of a vanilla redstone T flip flop, just the logical equivalent.

LuciusV commented 2 years ago

It's no problem to do with external block getting strong signal and adjacent machine working from it by weak signal, but I really want to see RS latch block implemented without needing to do Vanilla mechanic or tricky Delayer (it also crashed my game in strange way when I was debugging with screen what is going on with variables)