Jump to content




Random sentence[2]


  • You cannot reply to this topic
4 replies to this topic

#1 UrASmurf

  • New Members
  • 13 posts

Posted 19 July 2012 - 04: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?

#2 Lyqyd

    Lua Liquidator

  • Moderators
  • 8,465 posts

Posted 19 July 2012 - 05:00 AM

View PostUrASmurf, 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?

It's always easier to help when we can see the code involved.

#3 PixelToast

  • Signature Abuser
  • 2,265 posts
  • Location3232235883

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 UrASmurf

  • New Members
  • 13 posts

Posted 20 July 2012 - 01:18 AM

Er. Now it just says the first one over and over.

#5 Lyqyd

    Lua Liquidator

  • Moderators
  • 8,465 posts

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