13 posts
Posted 19 July 2012 - 05:53 AM
I got a little program to say a random phrase from a list I coded in:
Is there a way to make it so it does not say the same line twice in a row?
I would expect its like if phrase = something then bloop blop.
Also, where would I put term.clear() to have it clear after every said phrase?
8543 posts
Posted 19 July 2012 - 06:00 AM
I got a little program to say a random phrase from a list I coded in:
Is there a way to make it so it does not say the same line twice in a row?
I would expect its like if phrase = something then bloop blop.
Also, where would I put term.clear() to have it clear after every said phrase?
It's always easier to help when we can see the code involved.
2217 posts
Location
3232235883
Posted 19 July 2012 - 06:44 AM
this should work :3
phrases={"The cake is a lie","Pi is exactly 3.","Today is Friday the thirteenth."}
while phrase==lastPhrase do
phrase=phrases[math.random(1,#phrases)]
end
lastPhrase=phrase
print(phrase)
sleep(1)
shell.run("clear")
sorry for not responding to the original thread, i was tired
13 posts
Posted 20 July 2012 - 02:18 AM
Er. Now it just says the first one over and over.
8543 posts
Posted 20 July 2012 - 03:56 AM
That's because lastPhrase isn't getting set, so the while loop never is entered.