This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
Clockturn's profile picture

[1.5] Bundled Cable Peripherals

Started by Clockturn, 29 September 2012 - 12:35 PM
Clockturn #1
Posted 29 September 2012 - 02:35 PM
Right now, Peripherals only really work when attached directly. Would it be at all possible to make it so that a peripheral could be attached via Bundled Cables, and have them interface with the Peripheral library exactly like normal?

For the issue of multiple peripherals, you could implement them as a list. Directly connected peripherals (placed beside the block) act as the first and only peripheral in the list.

When a cable is connected, however, you can access the peripherals on the cable by an index. They are sorted by the distance on the cable. Where the distance is the same, the peripheral with the lowest X, Y or Z will be ordered lower - ie, if the cable distance is the same, and the blocks have the same X co-ordinate but different Y co-ordinates, the block with the lower Y will go on the list first)
You would probably want to cache this list in some manner, since presumably doing all that cable checking and searching every call would be a waste of resources.

Some additions to the API would need to be made, most likely:

-- Change:
peripheral.wrap(side[,number=1]) -- Returns the peripheral at the given index on that side. (or nil, if number is out of bounds)

-- Add:
peripheral.all(side) -- Returns a table of all peripherals on that side. k=number, v=peripheral type.

Then we can easily connect monitors via cables and whatnot.
Xfel #2
Posted 29 September 2012 - 03:31 PM
Something like this is already possible using the Peripheral Cables addon. Link is in my signature. It doesn't add anything to the api, and the adressing part is done by using color tags, but most of the requested features are supported. And as the color tag adress is included into the side parameter string (eg. "right:blue"), any existing script can use the the cables too.
Cloudy #3
Posted 29 September 2012 - 03:54 PM
We may implement peripheral cables in the future. However, rest assured they won't be using bundled cables as a piggyback - it would be our own solution.
Clockturn #4
Posted 29 September 2012 - 04:22 PM
Something like this is already possible using the Peripheral Cables addon. Link is in my signature. It doesn't add anything to the api, and the adressing part is done by using color tags, but most of the requested features are supported. And as the color tag adress is included into the side parameter string (eg. "right:blue"), any existing script can use the the cables too.
I'd seen those, and (don't take this as an insult!) I felt that a slightly more… vanilla (I guess?) approach would be nicer. Hard to put what I mean into words, it just feels like a 'mod' than a feature, and that bugs me. Damn my pseudo-OCD.

We may implement peripheral cables in the future. However, rest assured they won't be using bundled cables as a piggyback - it would be our own solution.
I suggest it with the RP2 cables simply so that we can use less different kinds of cables. It'd be pretty nice if when RP2 wasn't enabled, CC would substitute its own peripheral cable, though. Still, looking forward to it!
Cloudy #5
Posted 29 September 2012 - 04:27 PM
Piggybacking on RP2 would be ugly implementation wise and also would be inconsistent - so we won't be using them at all for that, even if RP2 is installed.
immibis #6
Posted 30 September 2012 - 01:42 AM
I suggest it with the RP2 cables simply so that we can use less different kinds of cables. It'd be pretty nice if when RP2 wasn't enabled, CC would substitute its own peripheral cable, though. Still, looking forward to it!

Bundled cables transmit 16 redstone signals. No more, no less. It would be stupid for CC to change the way RP2 features work.
Aquilamo #7
Posted 09 October 2012 - 11:53 AM
I suggest it with the RP2 cables simply so that we can use less different kinds of cables. It'd be pretty nice if when RP2 wasn't enabled, CC would substitute its own peripheral cable, though. Still, looking forward to it!

Bundled cables transmit 16 redstone signals. No more, no less. It would be stupid for CC to change the way RP2 features work.
I think Cloudy meant to implement a computercraft "bundled cabled", rather than using or modifying the RP2 bundled cables. I suggest naming it "optical fibers" as to avoid confusion, and to sound cooler. Besides, optical fibers are better than bundled cables, in real life…