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?
Random sentence[2]
Started by UrASmurf, Jul 19 2012 04:53 AM
4 replies to this topic
#1
Posted 19 July 2012 - 04:53 AM
#2
Posted 19 July 2012 - 05:00 AM
UrASmurf, on 19 July 2012 - 04:53 AM, said:
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?
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.
#3
Posted 19 July 2012 - 05: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
#4
Posted 20 July 2012 - 01:18 AM
Er. Now it just says the first one over and over.
#5
Posted 20 July 2012 - 02:56 AM
That's because lastPhrase isn't getting set, so the while loop never is entered.
1 user(s) are reading this topic
0 members, 1 guests, 0 anonymous users











