Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Is there a way I can create a Scale Factor in coding?

Asked by 9 years ago

If you learned Scale Factors in Algebra then you should be familiar with this term.

But anyways, my idea is to use math like where you have 2 fractions. But you put this into like an 'if' statement.

Like for every 1/5 25 is subtracted from a variable.

Does that make sense?

0
It makes no sense because your question is rendered completely differently on everyone else's browser. Please edit your question and preview it to make sure we see what you mean. Unclear 1776 — 9y
0
Tell me if that's any better NAWESOME14 40 — 9y
0
This doesn't make sense. Do you mind giving a better example... I have never heard of this term. Unclear 1776 — 9y
0
I'll try yeah. haha NAWESOME14 40 — 9y
View all comments (2 more)
0
"for every 1/5 25 is subtracted from a variable" What? Like every 1/5th seconds? Elaborate please. Goulstem 8144 — 9y
0
so like for every 1 subtracted from a variable. I'll use 'a', then 5 is subtracted from, say, 'b'. For every 1 subtracted from 'a', there is 5 subtracted from 'b'. Is that any clearer? NAWESOME14 40 — 9y

1 answer

Log in to vote
1
Answered by
BlackJPI 2658 Snack Break Moderation Voter Community Moderator
9 years ago

I'm having trouble understanding exactly what you want but is it something like this?

local a, b = 100, 100
local aScale, bScale = 1, 5

local function Add(amount)
    a = a + amount*aScale
    b = b + amount*bScale
end

local function Subtract(amount)
    a = a - amount*aScale
    b = b - amount*bScale
end

Using this, if you called Add(2), then

a = 100 + 2 * 1 = 102

b = 100 + 2 * 5 = 110

0
Yeah man, you got it. Thank you NAWESOME14 40 — 9y
Ad

Answer this question