misterhup
|
  |
| Joined: 07 Jul 2010 |
| Total Posts: 280 |
|
|
| 17 Jan 2016 01:26 PM |
Is it just in studio or mmath.random isnt random at all? If so, can you guys help me figutre out a function to get a random element from a table?
|
|
|
| Report Abuse |
|
|
|
| 17 Jan 2016 01:54 PM |
| It's random , you maybe just get the same thing over again and again and you are maybe really lucky xD |
|
|
| Report Abuse |
|
|
|
| 17 Jan 2016 01:55 PM |
| You can set a seed with math.randomseed(x), which will set x as the seed for the pseudo-random generator. |
|
|
| Report Abuse |
|
|
|
| 17 Jan 2016 01:58 PM |
math.randomseed(tick()) is what you want |
|
|
| Report Abuse |
|
|
misterhup
|
  |
| Joined: 07 Jul 2010 |
| Total Posts: 280 |
|
|
| 18 Jan 2016 09:54 AM |
I don't really know how to use it.. Can you give me an example? For example if I have a table "abc={"a","b","c"}" how do I get a random element out of it using "math.randomseed"?
|
|
|
| Report Abuse |
|
|
chimmihc
|
  |
| Joined: 01 Sep 2014 |
| Total Posts: 17143 |
|
|
| 18 Jan 2016 10:18 AM |
http://www.lua.org/pil/18.html
https://en.wikipedia.org/wiki/Pseudorandomness
|
|
|
| Report Abuse |
|
|
misterhup
|
  |
| Joined: 07 Jul 2010 |
| Total Posts: 280 |
|
|
| 18 Jan 2016 12:37 PM |
I'm dumb...Can I just get the example?
|
|
|
| Report Abuse |
|
|
nox7
|
  |
| Joined: 29 Aug 2008 |
| Total Posts: 27467 |
|
|
| 18 Jan 2016 12:40 PM |
This usually happens if you're testing repeatedly over and over in studio. We used to fix this back in the old days by doing this at the top:
math.random();math.random();math.random();
It calls and reseeds itself a bit before use. Fixes your issue. |
|
|
| Report Abuse |
|
|
misterhup
|
  |
| Joined: 07 Jul 2010 |
| Total Posts: 280 |
|
| |
|