Jump to content




Redstone signal in infinite loop


2 replies to this topic

#1 naburus

  • Members
  • 4 posts

Posted 01 April 2013 - 10:46 AM

I wanna do that the Computer always scan the redstone signal in infinte loop. What is the problem in my code?

	while true do
			if redstone.getInput("left",true) then
					redstone.setOutput("right", true)
					sleep(4)
					redstone.setOutput("right", false)
					break
			end
	end

Give me this error massage: red:2 Too long without yielding

#2 remiX

  • Members
  • 2,076 posts
  • LocationSouth Africa

Posted 01 April 2013 - 11:01 AM

a while true do loop is an infinite loop and will last until stopped manually or in this case redstone signal on the left is on

Added a os.pullEvent('redstone') to before the last end. This causes it to yield and only continue if a redstone signal is triggered.

Also the if needs to be
if redstone.getInput( 'left' ) == true then
--or
if rs.getInputed( 'left' ) then


#3 naburus

  • Members
  • 4 posts

Posted 01 April 2013 - 11:02 AM

Hmm ok so i need add this line os.pullEvent('redstone') ty. Now works.





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users