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

Random sentence[2]

Started by UrASmurf, 19 July 2012 - 03:53 AM
UrASmurf #1
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?
Lyqyd #2
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.
PixelToast #3
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
UrASmurf #4
Posted 20 July 2012 - 02:18 AM
Er. Now it just says the first one over and over.
Lyqyd #5
Posted 20 July 2012 - 03:56 AM
That's because lastPhrase isn't getting set, so the while loop never is entered.