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

Random sentence.

Started by UrASmurf, 18 July 2012 - 02:17 AM
UrASmurf #1
Posted 18 July 2012 - 04:17 AM
Hi, I am "newish" to computercraft. I discovered it in december 2011, but stopped using it/am a noob. Is there a way to put in a bunch of print("XXXXX")'s and have it say one at random when you run a program. I want to do something like program name fact, having it give me a random fact.

Tuts/code would help a bunch.
PixelToast #2
Posted 18 July 2012 - 04:27 AM

phrases={"The cake is a lie","Pi is exactly 3.","Today is Friday the thirteenth."}
print(phrases[math.random(1,#phrases)])
sleep(1)
inserted somewhere in the shell program
expand the table to whatever count you want
UrASmurf #3
Posted 18 July 2012 - 04:53 AM
Thank you so much, 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?