DHSR
|
  |
| Joined: 08 Mar 2015 |
| Total Posts: 1424 |
|
|
| 12 Aug 2016 09:35 AM |
I need to take this number
local base = (some random low or high number) local answer = ???
and have come up with an equation so that if base is high, the answer is low if the base is low, the answer is high
Trying to figure out an equation that'll work for this situation but nothing comes to mind This is for a script
[insert lame siggy here] |
|
|
| Report Abuse |
|
|
| |
|
DHSR
|
  |
| Joined: 08 Mar 2015 |
| Total Posts: 1424 |
|
|
| 12 Aug 2016 09:40 AM |
That will just bring every answer to negative
[insert lame siggy here] |
|
|
| Report Abuse |
|
|
WoolHat
|
  |
| Joined: 19 May 2013 |
| Total Posts: 1873 |
|
|
| 12 Aug 2016 09:41 AM |
| well, if we're doing positive values, you could try answer = 1/math.sqrt(math.abs(base)). The higher you go, the lower the answer. Only works for positive 1 to infinity though. Answers would range from greater than zero to one. |
|
|
| Report Abuse |
|
|
DHSR
|
  |
| Joined: 08 Mar 2015 |
| Total Posts: 1424 |
|
|
| 12 Aug 2016 09:41 AM |
I'll be more in-depth on this
local answer = has to be a number between 0.05 and 0 local base = is a number between 0 and 1
[insert lame siggy here] |
|
|
| Report Abuse |
|
|
| |
|
|
| 12 Aug 2016 09:43 AM |
local base = math.random()
local answer = 0.05-math.random()*0.05 |
|
|
| Report Abuse |
|
|
|
| 12 Aug 2016 09:44 AM |
Why do we call this "base" anyways? "Base" is a term usually just used in exponents, right?
|
|
|
| Report Abuse |
|
|
DHSR
|
  |
| Joined: 08 Mar 2015 |
| Total Posts: 1424 |
|
|
| 12 Aug 2016 09:45 AM |
Thank you so much Jarod.
[insert lame siggy here] |
|
|
| Report Abuse |
|
|
|
| 12 Aug 2016 09:46 AM |
lol im dumb i put math.random() in my answer when i should have put base lol
and jarod's is shorter anyway |
|
|
| Report Abuse |
|
|
DHSR
|
  |
| Joined: 08 Mar 2015 |
| Total Posts: 1424 |
|
|
| 12 Aug 2016 09:46 AM |
It's not called Base in my script. I was having trouble figuring out a formula for "spread" for a gun script, which calculates all other essential variables based on a fireRate and magCapacity
I'll give you what I have so you can understand what I'm doing
local magCapacity = 32 local fireRate = 0.16
local DmgFormula = math.ceil(100 / (2/fireRate) ) local HSFormula = math.ceil(DmgFormula + (DmgFormula/2) ) local Dmg = math.random(DmgFormula - HSFormula, DmgFormula + HSFormula ) local HS = math.random(Dmg - HSFormula, Dmg + HSFormula) local ReloadTime = math.ceil((fireRate / 2) * magCapacity)
[insert lame siggy here] |
|
|
| Report Abuse |
|
|
|
| 12 Aug 2016 09:48 AM |
| had you told us this in your original post you would have gotten answers way faster bruh |
|
|
| Report Abuse |
|
|
DHSR
|
  |
| Joined: 08 Mar 2015 |
| Total Posts: 1424 |
|
|
| 12 Aug 2016 09:50 AM |
I really doubt it, tbh lol
[insert lame siggy here] |
|
|
| Report Abuse |
|
|
WoolHat
|
  |
| Joined: 19 May 2013 |
| Total Posts: 1873 |
|
|
| 12 Aug 2016 09:57 AM |
| So, is the question answered or no? |
|
|
| Report Abuse |
|
|
DHSR
|
  |
| Joined: 08 Mar 2015 |
| Total Posts: 1424 |
|
|
| 12 Aug 2016 09:59 AM |
It's answered, yes. Jarod gave me the equation I've spent the last hour trying to figure out in 5 minutes, lol
local Spread = (1.16-fireRate) * 0.05
[insert lame siggy here] |
|
|
| Report Abuse |
|
|
DHSR
|
  |
| Joined: 08 Mar 2015 |
| Total Posts: 1424 |
|
|
| 12 Aug 2016 11:55 AM |
it appears I'm stuck again
I tried using Jarod's thing modified but it's not working for this
number = something between 0.16 and 1 answer needs to be something between 0.3 and 1.4 the higher the number is the lower answer has to be the lower answer is the higher number is need equation to do this
[insert lame siggy here] |
|
|
| Report Abuse |
|
|
DHSR
|
  |
| Joined: 08 Mar 2015 |
| Total Posts: 1424 |
|
|
| 12 Aug 2016 12:03 PM |
bump
[insert lame siggy here] |
|
|
| Report Abuse |
|
|
BanTech
|
  |
| Joined: 31 Dec 2015 |
| Total Posts: 886 |
|
|
| 12 Aug 2016 12:32 PM |
| (1 - (fireRate - 0.3) / 1.1) * 0.84 + 0.16 |
|
|
| Report Abuse |
|
|
WoolHat
|
  |
| Joined: 19 May 2013 |
| Total Posts: 1873 |
|
|
| 12 Aug 2016 12:51 PM |
could be overcomplicated. I didn't write out an actual formula for this, so it's definitely not simplified.
local input = .58 local inputrange = {min = 0.16,max = 1} local outputrange = {min = 0.3,max = 1.4}
if input < inputrange.min or input > inputrange.max then error("Out of range") else local inverseinputpercent = 1-((input-inputrange.max)/(inputrange.min - inputrange.max)) local outputrangetimespercent = inverseinputpercent * (outputrange.max - outputrange.min) local answer = outputrangetimespercent + outputrange.min print(answer) end |
|
|
| Report Abuse |
|
|
|
| 12 Aug 2016 01:03 PM |
local function Lerp(From, To, AlphaLow, AlphaHigh, Alpha) local Alpha = (Alpha-AlphaLow) / (AlphaHigh-AlphaLow) return To+(From-To)*Fraction end
-- number = something between 0.16 and 1 -- answer needs to be something between 0.3 and 1.4
Lerp(1.4, 0.3, 0.16, 1, number)
|
|
|
| Report Abuse |
|
|