28 posts
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
1548 posts
Location
That dark shadow under your bed...
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
28 posts
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).
1111 posts
Location
Portland OR
Posted 16 August 2012 - 08:24 AM
It's colors.white, plural colors not color.
1548 posts
Location
That dark shadow under your bed...
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
28 posts
Posted 16 August 2012 - 08:26 AM
Thank you, it works!
839 posts
Location
England
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.