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

Bundle Cable Input?

Started by Deo3560, 09 October 2012 - 11:55 PM
Deo3560 #1
Posted 10 October 2012 - 01:55 AM
Alright, I learned yesterday (I'm a novice) that I can send a redstone pulse to activate a command when linked to the appropriate side of the computer. Now, I wish to know how to use "BUNDLED CABLES". I know it is easy to activate a single cable using colors.yellow for example. I am curious to know if I can make a set up like this:
I'll just plug in 3 different codes if red, then - if green, then -, if yellow, then - however, I can only get it to work for 1 colored wire directly into the appropriate side like this:


Is it possible? If so, do you mind teaching me it or giving me a basic script?
I hope this is clear, if not I'll try to explain it better…
Lyqyd #2
Posted 10 October 2012 - 02:06 AM
Well, for one thing, the physical layout of the bundled cable matters. The second image is correct, but I don't think the first will connect properly (despite appearing to do so). Second, you will want to use the bundledInput/bundledOutput functions of the redstone library (see the wiki for details) and the colors API to make the colors easier to work with.
Deo3560 #3
Posted 10 October 2012 - 02:23 AM
Well, lets say I need to input 6 or so redstone currents on 1 monitor. However, two of the sides are use as outputs leaving me with only 4 more sides I can link as an input, but with 2 wires that there is no room to attach. I want to figure out how to attach a bundled cable to the monitor that supports the 2 other colors (or more) like the first picture where I tried to link 3 different colors to a bundle cable that is hooked into the monitor. I want them to be individually connected, like you can turn on green, red, OR yellow for different results that it collects and activates….

I don't know, I'm just experimenting…
Lyqyd #4
Posted 10 October 2012 - 02:40 AM
The only thing that might be wrong with the first image is that the corner where the wire turns toward the computer is the same block that it's also supposed to connect to the computer in. That might not work, so try moving the bundled cable away from it one more block, so that there's a straight piece going into the computer, like the second image.

After that, you need to use the correct API calls like I mentioned in my previous post. rs.getBundledInput, rs.setBundledOutput, etc. You can look these up on the wiki, in the redstone API.
Deo3560 #5
Posted 10 October 2012 - 02:49 AM
!!!! Genius I really appreciate the help, It works great, not I just have the rest of the program to script =P
Deo3560 #6
Posted 10 October 2012 - 04:26 AM
Err, may not have worked, this time the levers actually activated, however, all of the levers worked when only the yellow ones meant to trigger it for that circumstance


while true do
 local event, parameter = os.pullEvent("redstone")
 if redstone.getBundledInput("left", colors.yellow) then
  shell.run("1-2")
  end
end

(1-2 is the program which activates the elevator which goes up 5 blocks, pauses to allow people to exit, then goes back to floor one -5 blocks. That is a whole different program when my elevator relied on typing commands in to use the elevator rather than the click of a button). It will eventually be on one codes when I copy that code above, except add more colors.<color>

Is there anything I am doing wrong?:


If you are able to take a picture of something that will work, that would be great, visuals usually help.
Lyqyd #7
Posted 10 October 2012 - 04:40 AM
Err, may not have worked, this time the levers actually activated, however, all of the levers worked when only the yellow ones meant to trigger it for that circumstance


while true do
local event, parameter = os.pullEvent("redstone")
if redstone.getBundledInput("left", colors.yellow) then
  shell.run("1-2")
  end
end

(1-2 is the program which activates the elevator which goes up 5 blocks, pauses to allow people to exit, then goes back to floor one -5 blocks. That is a whole different program when my elevator relied on typing commands in to use the elevator rather than the click of a button). It will eventually be on one codes when I copy that code above, except add more colors.<color>

The code here is the problem, not the setup. What's going on is that getBundledInput returns the value of all of the colors that are on (each color is one bit of a sixteen-bit number in this case), so as long as any of them are on, it's returning more than 0 (which satisfies the if), which isn't what you're looking for. There are two options. You can use rs.testBundledInput instead, which does check for a specific color, or you can store the value that getBundledInput returns and then check it with colors.test to see if it has the specific color you're looking for.
Deo3560 #8
Posted 10 October 2012 - 09:10 PM
aha, that solved that problem, thank you Lyqyd, but I am sure I will run into another problem later on