ToroCraft / Minecoprocessors

Increase your redstone possibilities and learn assembly programming at the same time with the Minecoprocessors Minecraft Mod!
https://minecraft.curseforge.com/projects/minecoprocessors
GNU General Public License v3.0
33 stars 10 forks source link

Sugestion: A Way to Transfer Data #7

Closed Jonnycake closed 7 years ago

Jonnycake commented 7 years ago

Suggestion So, first, I love the mod, but one thing that I think would make it better is a way to transfer data from one processor (or other redstone source) to another so that you can translate a single input different outputs. At the moment, the only way to do it is to have it be based on how long a pulse is, but that comes with the added issue of needing to synchronize the sender and receiver perfectly making it impossible to use a chest as input, for example.

Use Case 1 - Split a single input into multiple outputs - I have ToughAsNails installed and it comes with a season detector which gives off a redstone signal if it's set to the correct season. You could take that information into one processor, choose a specific output you want to be enabled downstream, and pass it over a single wire (for example - to go through a doorway) - maybe to enable climatisation.

2 - You can take input from a chest and based on it's fullness, light up a different light (or turn on/off a different part of a circuit).

I'm sure there's a ton more, but 1 is what originally inspired the idea and 2 is a more generic ability that it would enable.

Possible Implementation The value could be based on the redstone strength of the input. That would be limited to 15, but that's large enough to use as a bitmask to determine which of the outputs need to be on (if splitting one input into 3 outputs).

Difficulty Was going through the code, doesn't look like it would be too hard to implement as you're already getting the signal strength when you determine if it's on or off, you'd just have to set that value directly rather than casting it to a boolean (I think, not entirely sure if other issues would come from that though).

frodare commented 7 years ago

Thanks for the suggestion!

I built the processor with one byte port registers instead of single bits with that type of functionality in mind. I had originally intended to make another mod that would add 8 bit bus blocks that could connect processors together and carry an entire byte, but I never got around to it. The bus block would have pins so that it could connect 8 redstone inputs (or outputs) to and send all that data as a one byte signal to a processor.

But that didn't happen, and it really looks like you are asking for an ADC. I could build in an auto ADC function that would update the top nibble with the redstone signal level of the port registers. A full signal would yield 0xF1 to the associated port register, and a signal strength of one would be 0x11. That would allow the register to mostly work as is, and provide a way to read the analog value (redstone level) of the input for more advanced use cases.

A DAC would be a little more involved since I would need to use a flag of some sort to switch a port to analog mode. I guess I could simply check the upper nibble for a non-zero value, and if one is set output an analog signal, so maybe not that difficult.

Jonnycake commented 7 years ago

Hah, yeah it did kind of look like there were a few features that just hadn't made it in yet, but yeah an ADC is exactly what I'm looking for :D

frodare commented 7 years ago

I am currently working on another project, but I am hoping to get back working on this one after it. I have created a new issue to track this request: #8