|
| 01 Nov 2017 01:36 PM |
SparksSEffect.PlaybackSpeed = 1
Instead of 1, how do I get it to be 0.9 through 1.2? |
|
|
| Report Abuse |
|
|
|
| 01 Nov 2017 01:43 PM |
| SparksSEffect.PlaybackSpeed = math.random(0.9, 1.2) |
|
|
| Report Abuse |
|
|
| |
|
chimmihc
|
  |
| Joined: 01 Sep 2014 |
| Total Posts: 17143 |
|
| |
|
|
| 01 Nov 2017 01:47 PM |
math.randomseed(tic)
function between (L, H)
return math.random() * (H - L) + L
end
between (.9, 1.2)
|
|
|
| Report Abuse |
|
|
|
| 01 Nov 2017 01:51 PM |
| *errors math.randomseed(tick()) function between (L, H) return math.random() * (H - L) + L end ##### = between (.9, 1.2) |
|
|
| Report Abuse |
|
|
| |
|
chimmihc
|
  |
| Joined: 01 Sep 2014 |
| Total Posts: 17143 |
|
|
| 02 Nov 2017 03:27 AM |
| It doesn't, it does the same thing as your original code, the value will always be 1. |
|
|
| Report Abuse |
|
|
Inigo18
|
  |
| Joined: 02 Feb 2014 |
| Total Posts: 1041 |
|
|
| 02 Nov 2017 04:55 AM |
| Chimmi is actually right, math.random will get an integer like 1,2,3. Thats why math.random(.9,1.2) will always get 1. |
|
|
| Report Abuse |
|
|
| |
|
Soybeen
|
  |
| Joined: 17 Feb 2010 |
| Total Posts: 21462 |
|
| |
|
annabet_h
|
  |
| Joined: 13 Mar 2016 |
| Total Posts: 1475 |
|
| |
|
|
| 02 Nov 2017 06:33 AM |
"^ that's not a thing" Did you try it? I could be wrong, but I don't see anything wrong with it.
If you don't want to do the math yourself, here's a good function.
local function random(a, b) return a+(b-a)*math.random() end
print(random(0.9, 1.2))
Same math as his, actually. 0.9+0.3*math.random() Yeah, his code should work perfectly.
|
|
|
| Report Abuse |
|
|
Soybeen
|
  |
| Joined: 17 Feb 2010 |
| Total Posts: 21462 |
|
|
| 02 Nov 2017 06:44 AM |
It looked cool, so I believed it, then questioned it. I tried it in rep.lit and got values in excess of 1, but maybe I did something wrong, let me check again
*doot doot time passes*
So I tried it again like this min,max = .3,.9 print(max+min*math.random())
and got these results
0.98 1.06 1.04 1.08 1.00 1.05 1.18 1.17 1.09 1.11
did I do something wrong? it's pretty much exactly what he said, unless there's some other proceedure I was supposed to assume from it. |
|
|
| Report Abuse |
|
|
|
| 02 Nov 2017 06:50 AM |
That isn't max+min*r, that's min+(max-min)*r
The value ranges from .9 to (.9 + .3) Required extra sentence here for filter dodging. Now, the upper constraint is 1.2, as originally specified in the OP's example post.
"Instead of 1, how do I get it to be 0.9 through 1.2?" That is what the values are.
If you wanted to get a number between 4.2 and 6.1, it would be 4.2 + (6.1 - 4.2)*r Required extra sentence here for filter dodging. 4.2 + 1.9*r
|
|
|
| Report Abuse |
|
|
Soybeen
|
  |
| Joined: 17 Feb 2010 |
| Total Posts: 21462 |
|
|
| 02 Nov 2017 06:56 AM |
Oh! My issue is that I just assumed .3 was the min and .9 was the max without referring back to the OP, where the min was .9 and the max was 1.2
|
|
|
| Report Abuse |
|
|
Luckyxero
|
  |
| Joined: 26 Feb 2014 |
| Total Posts: 505 |
|
|
| 02 Nov 2017 06:56 AM |
-_- noobs
math.random(90, 120) / 100 |
|
|
| Report Abuse |
|
|
Soybeen
|
  |
| Joined: 17 Feb 2010 |
| Total Posts: 21462 |
|
|
| 02 Nov 2017 06:58 AM |
| chim already gave that answer |
|
|
| Report Abuse |
|
|
|
| 02 Nov 2017 06:59 AM |
"math.random(90, 120) / 100" Noob.
local function lerp(a, b, c) c = c or math.random() return a+(b-a)*c end
lerp(.9, 1.2)
Seriously get on our level.
|
|
|
| Report Abuse |
|
|
Kiriot22
|
  |
| Joined: 19 Jul 2015 |
| Total Posts: 226 |
|
|
| 02 Nov 2017 07:01 AM |
| A nice discussion about math.random we have right there. |
|
|
| Report Abuse |
|
|
|
| 02 Nov 2017 07:15 AM |
"A nice discussion about math.random we have right there." It's not a discussion if my way is the only correct way to do it, and everyone else is flat out wrong.
|
|
|
| Report Abuse |
|
|
Soybeen
|
  |
| Joined: 17 Feb 2010 |
| Total Posts: 21462 |
|
|
| 02 Nov 2017 07:16 AM |
| i mean, if we want to get technical that's still a discussion |
|
|
| Report Abuse |
|
|
|
| 02 Nov 2017 07:18 AM |
It's not a discussion. If debate class taught me anything, it's that you can't have a discussion when I won't listen to reason.
|
|
|
| Report Abuse |
|
|
Soybeen
|
  |
| Joined: 17 Feb 2010 |
| Total Posts: 21462 |
|
| |
|
|
| 02 Nov 2017 07:23 AM |
Nope, why emulate someone like you when I can emulate myself?
|
|
|
| Report Abuse |
|
|