Posted 27 November 2012 - 02:56 PM
Hey Everyone. Making a control program for my omnidirectional inchworm engine. I have tested the engine extensively with levers and colored wire so I know its good, now i want to work on a program to control it automatically. I keep getting the "attempt to call nil" over and over on a lot of my lines. It either gives me an attempt to call nil error or it will crash when i enter the count input. Please advise? It gets to the 7th line from the bottom (give or take. ive made about 50 changes trying to troubleshoot this).
– Omnidirectional Control Panel –
–[[
Color Codes:
white:forward:1
black:right:32768
blue:left:2048
green:backward:8192
brown:up:4096
red:down:16384
]]–
function move(dir, cnt)
term.write("traveling")
col = 0
if dir == "fore" then
col = 1
elseif dir == "back" then
col = 8192
elseif dir == "left" then
col = 2048
elseif dir == "right" then
col = 32768
elseif dir == "up" then
col = 4096
elseif dir == "down" then
col = 16348
else
term.write("Incorrect Input. Try again")
do return end
end
while(cnt > 0) do
redstone.setBundledOutput("back", col)
sleep(0.75)
redstone.setOutput( "back", false )
sleep(0.75)
cnt=cnt-1
end
term.write("arrived")
end
term.clear()
term.setCursorPos(1,3)
textutils.slowPrint("Welcome to the Flutter Control Panel")
sleep(0.5)
term.clear()
term.setCursorPos(0,3)
textutils.slowPrint("Initializing")
sleep(0.5)
term.clear()
term.write("Please Choose from the following options:")
term.write("fore, back, left, right, up down")
while true do
term.print("enter a direction:")
local direction = read()
term.print("enter a count:")
local count = read()
move(direction,count)
end
– Omnidirectional Control Panel –
–[[
Color Codes:
white:forward:1
black:right:32768
blue:left:2048
green:backward:8192
brown:up:4096
red:down:16384
]]–
function move(dir, cnt)
term.write("traveling")
col = 0
if dir == "fore" then
col = 1
elseif dir == "back" then
col = 8192
elseif dir == "left" then
col = 2048
elseif dir == "right" then
col = 32768
elseif dir == "up" then
col = 4096
elseif dir == "down" then
col = 16348
else
term.write("Incorrect Input. Try again")
do return end
end
while(cnt > 0) do
redstone.setBundledOutput("back", col)
sleep(0.75)
redstone.setOutput( "back", false )
sleep(0.75)
cnt=cnt-1
end
term.write("arrived")
end
term.clear()
term.setCursorPos(1,3)
textutils.slowPrint("Welcome to the Flutter Control Panel")
sleep(0.5)
term.clear()
term.setCursorPos(0,3)
textutils.slowPrint("Initializing")
sleep(0.5)
term.clear()
term.write("Please Choose from the following options:")
term.write("fore, back, left, right, up down")
while true do
term.print("enter a direction:")
local direction = read()
term.print("enter a count:")
local count = read()
move(direction,count)
end