Posted 22 June 2012 - 08:17 PM
I am trying to create a program that randomly selects between three outputs and does not use the same output twice in a row. I got it to work a couple times but it crashes around the second or third time. I can thing of nothing that could fix it.
recent = "right"
x = math.random(1,3)
if x == 1 then
if recent == "left" then
os.reboot()
else
print("left")
recent = "left"
rs.setOutput("left", true)
sleep(1)
rs.setOutput("left", false)
os.reboot()
if x == 2 then
if recent == "middle" then
os.reboot()
else
print("middle")
recent = "middle"
rs.setOutput("back", true)
sleep(1)
rs.setOutput("back", false)
os.reboot()
end
if x == 3 then
if recent == "right" then
os.reboot()
else
print("right")
recent = "right"
rs.setOutput("right", true)
sleep(1)
rs.setOutput("right", false)
os.reboot()
end
end
end
end
end
I dont get it…