thane1326
|
  |
| Joined: 08 Apr 2009 |
| Total Posts: 867 |
|
|
| 24 Dec 2012 08:32 PM |
| Hey I'm trying to make a string randomizer, but it chooses from a list that I pick, not just any. Can someone help? |
|
|
| Report Abuse |
|
|
1Topcop
|
  |
| Joined: 09 Jun 2009 |
| Total Posts: 6635 |
|
|
| 24 Dec 2012 08:32 PM |
Strings = {"String","Stuff","Here"} print(Strings[math.random(1,#Strings)])
? |
|
|
| Report Abuse |
|
|
thane1326
|
  |
| Joined: 08 Apr 2009 |
| Total Posts: 867 |
|
|
| 24 Dec 2012 08:35 PM |
| Thanks, is their any way I can do it so it chooses two that go together? Becouse I'm making a game that You have to guess the phrase. like, Phrase = ("Hi", Banana's), ("No", "Pajamas") |
|
|
| Report Abuse |
|
|
|
| 24 Dec 2012 08:36 PM |
| Random pairs? Make another table and do the same thing. |
|
|
| Report Abuse |
|
|
|
| 24 Dec 2012 08:36 PM |
local words = {"Hello","Bye","apple","roblox"} -- Add your words here. print(words[math.random(1,#words)]) |
|
|
| Report Abuse |
|
|
| |
|
1Topcop
|
  |
| Joined: 09 Jun 2009 |
| Total Posts: 6635 |
|
|
| 24 Dec 2012 08:37 PM |
Like....
function trandom(t)return t[math.random(1,#t)]end Beg = {"Hello","Hi"} Fin = {"!","...","."} print(trandom(Beg)..trandom(Fin))
? |
|
|
| Report Abuse |
|
|
thane1326
|
  |
| Joined: 08 Apr 2009 |
| Total Posts: 867 |
|
|
| 25 Dec 2012 01:03 AM |
| OMG I don't understand that, but You just solved the problem to an awesome game, when it's done, I'll ask You how I can repay You. |
|
|
| Report Abuse |
|
|
thane1326
|
  |
| Joined: 08 Apr 2009 |
| Total Posts: 867 |
|
|
| 25 Dec 2012 01:24 AM |
| Wait, what if I wanted it so it didn't matter how much capitals they had, so it could be all caps, or all lowercase, becouse that's a problem too. |
|
|
| Report Abuse |
|
|
|
| 25 Dec 2012 02:57 AM |
:lower() :upper()
??
~ṡсɾïρτïṉģ hεlρεɾṡ ۩ lυαlεαɾṉεɾṡ ④ øƒвќṃṿј~ ღ ▂▃▅▆█ρεώḋïερïε☄сυτïερïε█▆▅▃▂ღ 【▬】 |
|
|
| Report Abuse |
|
|
jelly134
|
  |
| Joined: 25 Aug 2008 |
| Total Posts: 1137 |
|
|
| 25 Dec 2012 02:59 AM |
| if msg:lower() == phrase:lower() or msg:upper() == phrase:upper() then |
|
|
| Report Abuse |
|
|
peaspod
|
  |
| Joined: 29 Sep 2010 |
| Total Posts: 2809 |
|
|
| 25 Dec 2012 08:12 AM |
words = {"lol", "banana","troll"}
for i, v in pairs (words) do print(words[math.random(1, #words)] end |
|
|
| Report Abuse |
|
|
peaspod
|
  |
| Joined: 29 Sep 2010 |
| Total Posts: 2809 |
|
|
| 25 Dec 2012 08:13 AM |
I think I got that wrong:
fixed:
words = {"lol", "banana","troll"}
for i, v in pairs (words) do print(words[math.random(1, #v)] end |
|
|
| Report Abuse |
|
|
|
| 25 Dec 2012 10:58 AM |
words = {"lol", "banana","troll"} for i, v in pairs (words) do print(words[math.random(#words)] end
> Penguin Power |
|
|
| Report Abuse |
|
|