Posted 14 December 2012 - 12:49 PM
Hello all, I come to you today with a question that I know should be easier than I'm making it out to be. I am new to working with Lua, and am trying my hand at making a rather simple (in function) program. It just seems to hate me.
I want to make a program that does this:
1.Wait for a redstone input from a specific side (back, for instance)
2.Generate a single random number
3.Create a pulse specific to the number (for example, 1 creates a pulse on the right side, 2 on the back, etc)
4.Wait for a redstone input again.
The code I have so far is:
Help?
I want to make a program that does this:
1.Wait for a redstone input from a specific side (back, for instance)
2.Generate a single random number
3.Create a pulse specific to the number (for example, 1 creates a pulse on the right side, 2 on the back, etc)
4.Wait for a redstone input again.
The code I have so far is:
repeat
if redstone.getInput("back",true) then
i=math.random(1,3)
if i==1 then
redstone.setOutput("left",true)
sleep(0.5)
redstone.setOutput("left",false)
end
if i==2 then
redstone.setOutput("right",true)
sleep(0.5)
redstone.setOutput("right",false)
end
if i==3 then
redstone.setOutput("front",true)
sleep(0.5)
redstone.setOutput("front",false)
end
end
until a
But this cancels itself out after a moment, giving me the error "Too long without yielding," or it gives me a massive supply of random pulses.Help?