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

Code Repeat

Started by bastrian, 26 February 2012 - 12:08 PM
bastrian #1
Posted 26 February 2012 - 01:08 PM
Hi, sorry for that noob question but i am trying to repeat a code until a signal interrupts it.
I tryed it in this way:
http://pastebin.com/wn0Ldb4V

Anything works fine expect for the fact that that the program end
with the error "Too long whitout yielding".

I want that the programs checks like every 5/10 seconds if is there a input from bottom red, but it runs only once.

MfG
bastrian
Liraal #2
Posted 26 February 2012 - 01:57 PM

    repeat
	  if colors.test(rs.getBundledInput("bottom"), colors.red) == true then
term.clear()
term.setCursorPos(15,5)
print("Energie Verfügbar!")
rs.setBundledOutput("top", colors.green, true )
sleep(5)
elseif
colors.test(rs.getBundledInput("bottom"), colors.red) == false then
term.clear()
term.setCursorPos(15,5)
print("Keine Energie!")
rs.setBundledOutput("top", colors.red, true )
sleep(5)
    until colors.test(rs.getBundledInput("bottom"), colors.green) == true
end
Here you go
bastrian #3
Posted 26 February 2012 - 02:05 PM
Thanks for you help. Just a last question:
I get the error that lua expect a end to close if at line 2. I know what this error means, but i don't really know how to resolve it.
I cannot simply put a end on line 3, right?
Liraal #4
Posted 26 February 2012 - 02:07 PM
well, no, i suppose you should place 2 'end' after the sleep command. you need to close every if with an end