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

Error on basic redstone output program

Started by spun430, 03 September 2012 - 12:40 AM
spun430 #1
Posted 03 September 2012 - 02:40 AM
I am having problems with my first program. I am trying to run a basic redstone signal from right, back and left to a wireless transmitters. I want to just log in and see:

Welcome to East Quarry Control Computer
Please enter one of the following to activate:
1 - Water Pumps
2 - Quarry Engine 1
3 - Quarry Engine 2
_

Any help is greatly appreciated.. here is my code:


while true do
term.clear()
term.setCursorPos(1, 1)
print("Welcome to East Quarry Control Computer")
print("Please enter one of the following to activate:")
print("1 - Water Pumps")
print("2 - Quarry Engine 1")
print("3 - Quarry Engine 2")
input = io.read()
if input == "1" then
redstone.setOutput("right", true)
sleep(1)
redstone.setOutput("right", false)
end
else if input == "2" then
redstone.setOutput("back", true)
sleep(1)
redstone.setOutput("back", false)
end
else if input == "3" then
redstone.setOutput("left", true)
sleep(1)
redstone.setOutput("left", false)
end
else
term.clear
term.setCursorPos (1,1)
print("Incorrect input")
end
end
spun430 #2
Posted 03 September 2012 - 03:00 AM
I named the program startup so it would start on opening the computer and this is the error I get:

bios:206: [string "startup"]:15: 'end' expected
(to close 'while' at line 1)
Kazimir #3
Posted 03 September 2012 - 05:41 AM

while true do
term.clear()
term.setCursorPos(1, 1)
print("Welcome to East Quarry Control Computer")
print("Please enter one of the following to activate:")
print("1 - Water Pumps")
print("2 - Quarry Engine 1")
print("3 - Quarry Engine 2")
input = io.read()

  if input == "1" then
  redstone.setOutput("right", true)
  sleep(1)
  redstone.setOutput("right", false)
  elseif input == "2" then
  redstone.setOutput("back", true)
  sleep(1)
  redstone.setOutput("back", false)
  elseif input == "3" then
  redstone.setOutput("left", true)
  sleep(1)
  redstone.setOutput("left", false)
	else
	term.clear()
	term.setCursorPos (1,1)
	print("Incorrect input")
end
end
spun430 #4
Posted 03 September 2012 - 06:02 AM

while true do
term.clear()
term.setCursorPos(1, 1)
print("Welcome to East Quarry Control Computer")
print("Please enter one of the following to activate:")
print("1 - Water Pumps")
print("2 - Quarry Engine 1")
print("3 - Quarry Engine 2")
input = io.read()
if input == "1" then
redstone.setOutput("right", true)
sleep(1)
redstone.setOutput("right", false)
elseif input == "2" then
redstone.setOutput("back", true)
sleep(1)
redstone.setOutput("back", false)
elseif input == "3" then
redstone.setOutput("left", true)
sleep(1)
redstone.setOutput("left", false)
  else
  term.clear
  term.setCursorPos (1,1)
  print("Incorrect input")
end
end


now i get this error:

bios:206: [string "startup"]:25: '=' expected
sjele #5
Posted 03 September 2012 - 06:33 AM

while true do
term.clear()
term.setCursorPos(1, 1)
print("Welcome to East Quarry Control Computer")
print("Please enter one of the following to activate:")
print("1 - Water Pumps")
print("2 - Quarry Engine 1")
print("3 - Quarry Engine 2")
input = io.read()
if input == "1" then
redstone.setOutput("right", true)
sleep(1)
redstone.setOutput("right", false)
elseif input == "2" then
redstone.setOutput("back", true)
sleep(1)
redstone.setOutput("back", false)
elseif input == "3" then
redstone.setOutput("left", true)
sleep(1)
redstone.setOutput("left", false)
  else
  term.clear() --Added ()
  term.setCursorPos(1,1) -- Removed a space between Pos and ()
  print("Incorrect input")
end
end
spun430 #6
Posted 03 September 2012 - 07:09 AM
awesome! thank you guys for the help… works great now..