Posted 20 May 2013 - 07:43 PM
function menu()
term.clear()
term.setCursorPos(1,1)
print("Airship Control")
print("Options: Left, Right, Back, foward, Up, Down")
print("Choose a Direction:")
direction = read()
print("Choose an amount, leave nil for infinite")
value = read()
if direction == "left" or direction == "Left" then
parallel.waitForAll(repeatcontrol, left)
end
if direction == "right" or direction == "Right" then
parallel.waitForAll(repeatcontrol, right)
end
if direction == "foward" or direction == "Foward" then
parallel.waitForAll(repeatcontrol, foward)
end
if direction == "back" or direction == "Back" then
parallel.waitForAll(repeatcontrol, back)
end
if direction == "up" or direction == "Up" then
parallel.waitForAll(repeatcontrol, up)
end
if direction == "down" or direction == "Down" then
parallel.waitForAll(repeatcontrol, down)
end
end
left = function()
print("Press Any Button To Stop")
while dorepeat == true do
c = colors.combine(c, colors.blue)
rs.setBundledOutput("back", c)
os.sleep(3)
c = colors.subtract(c, colors.blue)
rs.setBundledOutput("back", c)
end
end
right = function()
print("Press Any Button To Stop")
while dorepeat == true do
c = colors.combine(c, colors.white)
rs.setBundledOutput("back", c)
os.sleep(3)
c = colors.subtract(c, colors.white)
rs.setBundledOutput("back", c)
end
end
back = function()
print("Press Any Button To Stop")
while dorepeat == true do
c = colors.combine(c, colors.lime)
rs.setBundledOutput("back", c)
os.sleep(3)
c = colors.subtract(c, colors.lime)
rs.setBundledOutput("back", c)
end
end
foward = function()
print("Press Any Button To Stop")
while dorepeat == true do
c = colors.combine(c, colors.yellow)
rs.setBundledOutput("back", c)
os.sleep(3)
c = colors.subtract(c, colors.yellow)
rs.setBundledOutput("back", c)
end
end
up = function()
print("Press Any Button To Stop")
while dorepeat == true do
c = colors.combine(c, colors.red)
rs.setBundledOutput("back", c)
os.sleep(3)
c = colors.subtract(c, colors.red)
rs.setBundledOutput("back", c)
end
end
down = function()
print("Press Any Button To Stop")
while dorepeat == true do
c = colors.combine(c, colors.orange)
rs.setBundledOutput("back", c)
os.sleep(3)
c = colors.subtract(c, colors.orange)
rs.setBundledOutput("back", c)
end
end
repeatcontrol = function()
dorepeat = "true"
while dorepeat == true do
if os.pullEvent("key") then
dorepeat = "false"
end
end
end
while true do
menu()
end
Hello! My functions do not wait for a keypress before closing.. Ignore the amount value, I've not implemented it yet.
Thank you!