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

[Lua][Error] Somthing i cant find :(

Started by _Stoned_Panda_, 09 October 2012 - 05:55 PM
_Stoned_Panda_ #1
Posted 09 October 2012 - 07:55 PM
So i am trying to make a program that opens a massive gate for me, just one problem im getting
bios:206: [string "gate"]:51: 'end' expected (to close 'while' at line 1)

while true do
  term.clear()
  term.setCursorPos(1,1)
  print("Open Or Close?")
  if input == "Close" then
	redstone.setOutput("back", true)
	sleep(1)
	redstone.setOutput("back", false)
	sleep(1)
	redstone.setOutput("back", true)
	sleep(1)
	redstone.setOutput("back", false)
	sleep(1)
	redstone.setOutput("back", true)
	sleep(1)
	redstone.setOutput("back", false)
	sleep(1)
	redstone.setOutput("back", true)
	sleep(1)
	redstone.setOutput("back", false)
	sleep(1)
	redstone.setOutput("back", true)
	sleep(1)
	redstone.setOutput("back", false)
	sleep(1)
	print("Closed Now!")
  end
  if input == "Open" then
	redstone.setOutput("right", true)
	sleep(1)
	redstone.setOutput("right", false)
	sleep(1)
	redstone.setOutput("right", true)
	sleep(1)
	redstone.setOutput("right", false)
	sleep(1)
	redstone.setOutput("right", true)
	sleep(1)
	redstone.setOutput("right", false)
	sleep(1)
	redstone.setOutput("right", true)
	sleep(1)
	redstone.setOutput("right", false)
	sleep(1)
	redstone.setOutput("right", true)
	sleep(1)
	redstone.setOutput("right", false)
	sleep(1)
	print("Open Now!")
  end
  else
	print("Command Not Recognised")
	print("Try With CAPS")
  end
end
Thanks in advance guys
Lyqyd #2
Posted 09 October 2012 - 08:04 PM

while true do
  term.clear()
  term.setCursorPos(1,1)
  print("Open Or Close?)
  local input = read() --You never got input. Added this.
  if string.lower(input) == "close" then --string.lower allows any capitalization of the word to be correct.
	redstone.setOutput("back", true)
	sleep(1)
	redstone.setOutput("back", false)
	sleep(1)
	redstone.setOutput("back", true)
	sleep(1)
	redstone.setOutput("back", false)
	sleep(1)
	redstone.setOutput("back", true)
	sleep(1)
	redstone.setOutput("back", false)
	sleep(1)
	redstone.setOutput("back", true)
	sleep(1)
	redstone.setOutput("back", false)
	sleep(1)
	redstone.setOutput("back", true)
	sleep(1)
	redstone.setOutput("back", false)
	sleep(1)
	print("Closed Now!")
  elseif string.lower(input) == "open" then --elseif is your friend. 
	redstone.setOutput("right", true)
	sleep(1)
	redstone.setOutput("right", false)
	sleep(1)
	redstone.setOutput("right", true)
	sleep(1)
	redstone.setOutput("right", false)
	sleep(1)
	redstone.setOutput("right", true)
	sleep(1)
	redstone.setOutput("right", false)
	sleep(1)
	redstone.setOutput("right", true)
	sleep(1)
	redstone.setOutput("right", false)
	sleep(1)
	redstone.setOutput("right", true)
	sleep(1)
	redstone.setOutput("right", false)
	sleep(1)
	print("Open Now!")
  --end before else block is incorrect.
  else
	print("Command Not Recognised")
  end
end

Try that. See comments for corrections made.
_Stoned_Panda_ #3
Posted 09 October 2012 - 09:47 PM

while true do
  term.clear()
  term.setCursorPos(1,1)
  print("Open Or Close?)
  local input = read() --You never got input. Added this.
  if string.lower(input) == "close" then --string.lower allows any capitalization of the word to be correct.
	redstone.setOutput("back", true)
	sleep(1)
	redstone.setOutput("back", false)
	sleep(1)
	redstone.setOutput("back", true)
	sleep(1)
	redstone.setOutput("back", false)
	sleep(1)
	redstone.setOutput("back", true)
	sleep(1)
	redstone.setOutput("back", false)
	sleep(1)
	redstone.setOutput("back", true)
	sleep(1)
	redstone.setOutput("back", false)
	sleep(1)
	redstone.setOutput("back", true)
	sleep(1)
	redstone.setOutput("back", false)
	sleep(1)
	print("Closed Now!")
  elseif string.lower(input) == "open" then --elseif is your friend.
	redstone.setOutput("right", true)
	sleep(1)
	redstone.setOutput("right", false)
	sleep(1)
	redstone.setOutput("right", true)
	sleep(1)
	redstone.setOutput("right", false)
	sleep(1)
	redstone.setOutput("right", true)
	sleep(1)
	redstone.setOutput("right", false)
	sleep(1)
	redstone.setOutput("right", true)
	sleep(1)
	redstone.setOutput("right", false)
	sleep(1)
	redstone.setOutput("right", true)
	sleep(1)
	redstone.setOutput("right", false)
	sleep(1)
	print("Open Now!")
  --end before else block is incorrect.
  else
	print("Command Not Recognised")
  end
end

Try that. See comments for corrections made.
will now, Thanks