Posted 03 October 2012 - 02:47 AM
I'm fairly new to programming and cc, but am learning quickly. I've watched tons of videos and gotten a few ideas and pieces of code from the forums before posting, but I still don't know where I am going wrong.
I am trying to write a program to extend or retract a drawbridge. I'm not sure where I am going wrong, when I pulse the cables in the interactive lua command the bridge will move, but it won't with the program.
I am trying to write a program to extend or retract a drawbridge. I'm not sure where I am going wrong, when I pulse the cables in the interactive lua command the bridge will move, but it won't with the program.
local function pulse(side, colors, time)
rs.setBundledOutput(side, colors)
sleep(time/2)
rs.setBundledOutput(side, 0)
sleep(time/2)
end
function open()
for i=1, 6 do
pulse("back", colors.orange, 2)
end
end
function close()
for i=1, 6 do
pulse("back", colors.white, 2)
end
end
function main()
term.clear()
term.setCursorPos(1,1)
write("Open or close ? ")
input = read()
if input == open then
open()
elseif input == close then
close()
end
end
main()