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

Bundled Cable Help

Started by Shinryuu, 19 September 2012 - 07:14 PM
Shinryuu #1
Posted 19 September 2012 - 09:14 PM
What am I doing wrong?

print("Type open to open the gates or close to close them.")
input = read()
if input == "open" then
  print("Opening...")
  color = colors.yellow
elseif input == "close" then
  print("Closing...")
  color = colors.white
elseif input == "debug" then
  exit()
else
  os.reboot()
end
o = 1
while o < 8 do
  rs.setBundledOutput("back",color)
  o = o + 1
  sleep(1)
  rs.setBundledOutput("back",0)
  sleep(1)
end
os.reboot()

Cranium #2
Posted 19 September 2012 - 09:27 PM
What exactly are you trying to accomplish? Is this supposed to output a pulse 8 times when opening and closing?
cheekycharlie101 #3
Posted 19 September 2012 - 09:39 PM
i have a suggestion. instead of using a while loop try a for loop. so

if input == "open" then
for i = 1,8 do
-- code here
end


for the 1,8 part it will make all the code repeat 8 times. i havent used bundeld cables much but i think if you did

rs.setBundledOutput("back", colors.yellow)
sleep(0.1)
rs.setBundledOutput("back", 0)
if you put that inside the for loop it might work.
MysticT #4
Posted 19 September 2012 - 09:45 PM
What's the problem? Did it throw an error?
The only error I see there is exit(), there's no such function. There's some other things that can be changed/improved, but it should work like that.
Maome #5
Posted 19 September 2012 - 09:49 PM
i have a suggestion. instead of using a while loop try a for loop. so

if input == "open" then
for i = 1,8 do
-- code here
end


for the 1,8 part it will make all the code repeat 8 times. i havent used bundeld cables much but i think if you did

rs.setBundledOutput("back", colors.yellow)
sleep(0.1)
rs.setBundledOutput("back", 0)
if you put that inside the for loop it might work.

Don't forget the extra sleep after turning off the output. Also depending on if you're using redpower/bc machines or pistons you'll need to keep the pulses above .5 or 1s to get them to always register properly.
Luanub #6
Posted 19 September 2012 - 09:51 PM
First declare color before you use it. So at the top add.

local color = 0

Two use local vars as I did above, it will save you from having conflicts and other issues down the road. It's best practice to always use local vars/function where you can.

Third exit() is not a valid Lua function, you will need to create your own.
Luanub #7
Posted 19 September 2012 - 09:53 PM
i have a suggestion. instead of using a while loop try a for loop. so

if input == "open" then
for i = 1,8 do
-- code here
end


for the 1,8 part it will make all the code repeat 8 times. i havent used bundeld cables much but i think if you did

rs.setBundledOutput("back", colors.yellow)
sleep(0.1)
rs.setBundledOutput("back", 0)
if you put that inside the for loop it might work.

Don't forget the extra sleep after turning off the output. Also depending on if you're using redpower/bc machines or pistons you'll need to keep the pulses above .5 or 1s to get them to always register properly.

Some of the RP machines will recognize a .1 second pulse. Others work well at .2 second pulses(the minimum for the RP Timer). .5 &amp; 1 second can be a little high and inefficient at times.

However with frames make sure you are giving the motor adequate time to do its things. It will recognize the pulses, but if it is in the middle of moving its going to ignore them.
KaoS #8
Posted 20 September 2012 - 06:20 AM
lol, c'mon people you should have noticed, we have had problems like this before… you cannot place the bundled cable ON the computer, it must be next to it or it does not connect
Cruor #9
Posted 20 September 2012 - 08:05 AM
Yes Kaos is correct, the cable isnt counted as conected in that "position", if you need to do it "directly" on the side of a computer you'll have to place a jacketed bundled aswell.
Shinryuu #10
Posted 20 September 2012 - 08:08 AM
Yup that should be it, thanks.