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

[Turtle][While not rs.getInput(rsSide): Need a new pair of eyes! cant find the mistake..!

Started by plazter, 21 May 2013 - 03:55 PM
plazter #1
Posted 21 May 2013 - 05:55 PM
Hello!

- i know this might be a noobish question.. but i really cant find my mistake here :/ it says that in line 14 there is a mistake:S
the fail is: "bios:338: [string "redstone"] : 14: 'end' expected (too close to 'while' at line 12)"

local rsSide = "left"
function run()
   turtle.suck()
	 for i = 1,16 do
	   turtle.select(i)
	 turtle.dropDown()
  end
sleep(3)
end
	while not rs.getInput(rsSide) do
	   run()
	 else  -- this is line 14 where it says fail is
   sleep(5)
end

Can you help me? :)/>
regard plazter

EDIT: got it working with

local rsSide = "left"
function run()
turtle.suck()
  for i = 1,16 do
  turtle.select(i)
  turtle.dropDown()
end
sleep(3)
end
if not rs.getInput(rsSide) then

  repeat run()

  until os.pullEvent("redstone")
run()
end


Thanks for the help otherwise! :D/>
will return if it shows to fail :)/>

EDIT: Dont use it.. semi works but fails since it just stops the program XD
Edited on 21 May 2013 - 04:06 PM
SadKingBilly #2
Posted 21 May 2013 - 06:00 PM
You're treating your while loop like it's an if statement. If you get rid of lines 14 and 15, it should work.
H4X0RZ #3
Posted 21 May 2013 - 06:03 PM
You can't use an else in a while loop.
Try this:

--your run() function etc. comes here.

while true do
if not rs.getInput("yourSide") then
run()
else
sleep(howManySeconds)
end
end
edit: I've got ninjad :D/>
plazter #4
Posted 21 May 2013 - 06:09 PM
You can't use an else in a while loop.
Try this:

--your run() function etc. comes here.

while true do
if rs.getInput("yourSide") then
run()
else
sleep(howManySeconds)
end
end
edit: I've got ninjad :D/>

Doesn't work :P/> it still executes the run function :)/>