Jump to content




redstone signal loop


2 replies to this topic

#1 xInDiGo

  • Members
  • 105 posts

Posted 03 May 2013 - 01:12 PM

i'm trying to make a startup script that will check for a redstone signal. if the redstone signal is true it will do some functions, if not it will sit and wait for the redstone signal. this is what i've got so far but its not working :(

while redstone.getInput("right") == true do
	    place()
	    drop()
	    else
	    sleep(1)
end

the error i get is "bios:383: [string "startup"]:27: 'end' expected (to close 'while' at line 24)"

i've added extra ends around line 27 but its not helping. thanks for the support!

#2 Smiley43210

  • Members
  • 204 posts

Posted 03 May 2013 - 01:18 PM

While loops don't take "else" conditions. If statements do. In this case, consider trying
while true do
  if redstone.getInput("right") then -- We don't need to say == true because if statements just check if the condition evaluates to true'
	place()
	drop()
  else
	sleep(1)
  end
end
Also, remember that to break out of any loop (while, for, repeat), you must use "break" (without the quotation marks).

#3 xInDiGo

  • Members
  • 105 posts

Posted 03 May 2013 - 02:25 PM

thanks very much! :)





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users