Jump to content




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


  • You cannot reply to this topic
3 replies to this topic

#1 plazter

  • Members
  • 134 posts

Posted 21 May 2013 - 04: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 by plazter, 21 May 2013 - 05:06 PM.


#2 SadKingBilly

  • Members
  • 160 posts

Posted 21 May 2013 - 05: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.

#3 H4X0RZ

  • Members
  • 1,315 posts
  • LocationGermany

Posted 21 May 2013 - 05: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

#4 plazter

  • Members
  • 134 posts

Posted 21 May 2013 - 05:09 PM

View PostFreack100, on 21 May 2013 - 05:03 PM, said:

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 :)





3 user(s) are reading this topic

0 members, 3 guests, 0 anonymous users