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

Input to Output

Started by eddie86, 20 August 2012 - 09:47 AM
eddie86 #1
Posted 20 August 2012 - 11:47 AM
Hi new to lua and have tried to figure this out for myself before asking this.
Quite simple, all I want to do is use an input from a bundled cable to bring on an output on a bundled cable.
If somone could show me an example of this it I would be very grateful.
Cranium #2
Posted 20 August 2012 - 01:40 PM
Input = Output????? What sorcery are you using? What are you trying to do? Your description is a little vague. If my early morning brain is working… You want to make a repeater since bundled cable only goes so far, and have a computer listen for an input, and change the same state on the other side?
sjele #3
Posted 20 August 2012 - 01:44 PM

getIn = rs.getBundledInput("back", colors.red) --Change back to what side it's on, and red to the color you would like to test.
if getIn then
  rs.setBundledOutput("back", colors.blue)   --Change back to side, and blue to what line you want to have on
end
eddie86 #4
Posted 20 August 2012 - 01:46 PM
if rs.getBundledInput("left", colors.white) then rs.getBundledOutput("right", colors.orange)
end

Can you explain why that doesnt work?
sjele #5
Posted 20 August 2012 - 01:55 PM
If input is white, it then checks for orange in you're code, make it this:

if rs.getBundledInput("left", colors.white) then
  rs.setBundledOutput("right", colors.orange)
end
getBundledInput: return true or false, on specified line/color.
setBundledOutput: Sets on/off status on the spesified line/color.
getBundledOutput: Returns true if the specified line is one, else it will return false-
eddie86 #6
Posted 20 August 2012 - 02:15 PM
I've done what you said above but the orange output is constanly on regardless of the state of the white input.
sjele #7
Posted 20 August 2012 - 02:24 PM

while true do
  sleep(.1)
  k = rs.getBundledInput("left", colors.white)
  if k then
    rs.setBundledOutput("right", colors.orange)
  else
    rs.setBundledOutput("right",colors.gray) --I just set gray to turn orange off.
end
Cranium #8
Posted 20 August 2012 - 03:00 PM

while true do
  os.pullEvent("redstone")
  redstone.setBundledOutput("right", redstone.getBundledInput("left"))
end
I have tested my code I posted, it works with changing output. For every change in input state, it updates the other side. In this instance, using os.pullEvent is a little more reliable. Otherwise, you might get a too long without yielding error. Just make sure the first one is the output, and the second is input.