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

Help with bundeled output

Started by xxx, 16 August 2012 - 06:11 AM
xxx #1
Posted 16 August 2012 - 08:11 AM
I'm trying to make a program which when run will send 3 pulses of white color redstone output through a bundled cable.
I haven't coded Lua in a long time, so this should be easy for you guys, but I can't figure it out myself, nor with Google.

Thanks for all help!


My code:

rs.setBundledOutput("back", color.white)
os.sleep(1)
rs.setBundledOutput("back", color.white)
os.sleep(1)
rs.setBundledOutput("back", color.white)
os.sleep(1)
shell.run("clear")
end
KaoS #2
Posted 16 August 2012 - 08:16 AM
close, you just need to clear the output between pulses


rs.setBundledOutput("back", color.white)
os.sleep(0.5)
rs.setBundledOutput("back",0)
os.sleep(0.5)
rs.setBundledOutput("back", color.white)
os.sleep(0.5)
rs.setBundledOutput("back",0)
os.sleep(0.5)
rs.setBundledOutput("back", color.white)
os.sleep(0.5)
rs.setBundledOutput("back",0)

and the end is unneeded
xxx #3
Posted 16 August 2012 - 08:20 AM
Thank you for the quick help!

I did exactly what you wrote, but i do only get "attempt to index ? (a nil value).
Luanub #4
Posted 16 August 2012 - 08:24 AM
It's colors.white, plural colors not color.
KaoS #5
Posted 16 August 2012 - 08:25 AM
sorry lol, I was just copying and adapting it… made a blind mistake, corrected again


rs.setBundledOutput("back", colors.white)
sleep(0.5)
rs.setBundledOutput("back",0)
sleep(0.5)
rs.setBundledOutput("back", colors.white)
sleep(0.5)
rs.setBundledOutput("back",0)
sleep(0.5)
rs.setBundledOutput("back", colors.white)
sleep(0.5)
rs.setBundledOutput("back",0)

It's colors.white, plural colors not color.

yep, beat me to it
xxx #6
Posted 16 August 2012 - 08:26 AM
Thank you, it works!
Pharap #7
Posted 16 August 2012 - 09:29 AM
To condense it do:

for cnt = 1,3 do
rs.setBundledOutput("back", colors.white)
sleep(0.5)
rs.setBundledOutput("back",0)
sleep(0.5)
end
A for loop (for varaible = startnumber,endnumber do end)
will go through the stuff in it with the set variable going up one each time.
Useful for doing something a set number of times or doing something for a multitude of numbers.